www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11983] New: RDMD masks out segmentation faults

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983

           Summary: RDMD masks out segmentation faults
           Product: D
           Version: D2
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: puneet coverify.org


--- Comment #0 from Puneet Goel <puneet coverify.org> 2014-01-24 06:54:47 PST
---
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;
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2014-01-31
00:01:23 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983



--- Comment #2 from Puneet Goel <puneet coverify.org> 2014-01-31 00:09:48 PST
---
(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 <code dawg.eu> Date: Mon Jan 27 14:50:47 2014 -0800 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983



--- Comment #3 from Puneet Goel <puneet coverify.org> 2014-01-31 00:35:33 PST
---
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;
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983



--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2014-01-31
01:20:09 PST ---
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().

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net
          Component|DMD                         |tools


--- Comment #5 from Lars T. Kyllingstad <bugzilla kyllingen.net> 2014-01-31
06:45:27 PST ---
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".

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983



--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2014-01-31
21:22:46 PST ---
https://github.com/D-Programming-Language/tools/pull/111

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei erdani.com


--- Comment #7 from Andrei Alexandrescu <andrei erdani.com> 2014-02-01 10:49:58
PST ---
Relevant info from Walter for the record:
https://stackoverflow.com/questions/1101957/are-there-any-standard-exit-status-codes-in-linux

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |thecybershadow gmail.com


--- Comment #8 from Vladimir Panteleev <thecybershadow gmail.com> 2014-02-01
21:20:35 EET ---
Reposting this here, pull which fixes regression by restoring old behavior:

https://github.com/D-Programming-Language/tools/pull/112

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983



--- Comment #9 from github-bugzilla puremagic.com 2014-02-02 13:32:12 PST ---
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

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 02 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11983


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 02 2014