Bug 11983 – RDMD masks out segmentation faults

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
tools
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-01-24T06:54:00Z
Last change time
2014-02-02T20:51:08Z
Keywords
pull
Assigned to
nobody
Creator
puneet

Comments

Comment #0 by puneet — 2014-01-24T06:54:47Z
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; }
Comment #1 by bugzilla — 2014-01-31T00:01:23Z
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.
Comment #2 by puneet — 2014-01-31T00:09:48Z
(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".
Comment #6 by bugzilla — 2014-01-31T21:22:46Z
Comment #7 by andrei — 2014-02-01T10:49:58Z
Comment #8 by dlang-bugzilla — 2014-02-01T11:20:35Z
Reposting this here, pull which fixes regression by restoring old behavior: https://github.com/D-Programming-Language/tools/pull/112
Comment #9 by github-bugzilla — 2014-02-02T13:32:12Z
Commits pushed to master at https://github.com/D-Programming-Language/tools https://github.com/D-Programming-Language/tools/commit/524a76ecc5f654f13eb3854cd4a2bc757eca3b19 rdmd_test: Add test for issue 11983 https://github.com/D-Programming-Language/tools/commit/ef71a52ddf5f59fb31a7dcd9d1fa4c025f1b919d Merge pull request #113 from CyberShadow/rdmd-20140202 rdmd: Fix `--dry-run`, add test for issue 11983