When executed with RDMD (github HEAD), the following code does not report segmentation fault. RDMD is returning exit code 245 instead of 139 on my ubuntu box. RDMD 2.064.2 does report segmentation fault.
void main() {
int* foo;
*foo = 4;
}
(In reply to comment #1)
> I don't really understand this report. Neither exit code 245 nor 139 have any
> specific purpose:
>
> http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
>
> and all rdmd does is return the exit code of the program it runs.
I am not sure of the purpose of the exit codes. I know these because I have been using these in my dustmite scripts.
Apart from the exit codes, rdmd is not even printing the usual "Segmentation fault (core dumped)" on my ubuntu 13.10 box. Previous versions of rdmd do that.
$ rdmd /tmp/test.d # no output on screen
$ ~/local/dmd-2.064/dmd2/linux/bin64/rdmd /tmp/test.d
Segmentation fault (core dumped)
I am using the latest version of the tools directory:
$ git show
commit 49cdc64116ba109352b661a3b3a5968d4c1afef9
Merge: 3a4b295 2ac7c99
Author: Martin Nowak <[email protected]>
Date: Mon Jan 27 14:50:47 2014 -0800
Comment #3 by puneet — 2014-01-31T00:35:33Z
Ok, I could confirm this on another ubuntu 13.10 (32 bit) machine as well.
root@amstredam:/tmp# rdmd test.d # exits silently
root@amstredam:/tmp# echo $?
245
root@amstredam:/tmp# rdmd --build-only test.d
root@amstredam:/tmp# ./test
Segmentation fault (core dumped)
root@amstredam:/tmp# echo $?
139
root@amstredam:/tmp# cat test.d
void main() {
int* foo;
*foo = 4;
}
Comment #4 by bugzilla — 2014-01-31T01:20:09Z
I did find something interesting (running on Ubuntu):
---------------------
rdmd> ./rdmd foo.d
rdmd>
rdmd> echo $?
245
rdmd> dmd foo.d
rdmd> ./foo
hello
Segmentation fault
rdmd> echo $?
139
---------------------
There's the 139 and 245 you were talking about. Looking at the source to rdmd:
private int run(string[] args, string output = null)
{
import std.conv;
yap(args.text);
if (dryRun) return 0;
File outputFile;
if (output)
outputFile = File(output, "wb");
else
outputFile = stdout;
auto process = spawnProcess(args, stdin, outputFile);
return process.wait();
}
so it must have something to do with spawnProcess() and wait().
Comment #5 by bugzilla — 2014-01-31T06:45:27Z
When the child process is terminated by a signal, wait() returns a negative number whose absolute value is the sigmal number. In this case, the signal is SIGSEGV, or 11, so wait() returns -11. Rdmd apparently uses this directly as its exit code, and since POSIX exit codes are restricted to the range 0-255, it wraps around to 245.
In other words, rdmd should probably check the value of wait(), and print something like "Terminated by signal X" if it is negative.
The 139 is set by the shell. Explanation here:
https://stackoverflow.com/questions/1101957/are-there-any-standard-exit-status-codes-in-linux
Since this is an RDMD bug (if that), I'm changing "Component" from "DMD2" to "tools".