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



---
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



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




---

 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. $ ~/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




---
Ok, I could confirm this on another ubuntu 13.10 (32 bit) machine as well.



245


Segmentation fault (core dumped)

139

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




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



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




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



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



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




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


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