Thread overview
[Issue 4809] New: Stack trace when throwing exception misses location of the throw statement
Sep 04, 2010
Rainer Schuetze
Oct 15, 2011
Rainer Schuetze
September 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4809

           Summary: Stack trace when throwing exception misses location of
                    the throw statement
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean@invisibleduck.org
        ReportedBy: r.sagitario@gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario@gmx.de> 2010-09-04 05:51:32 PDT ---
Under windows, the following code

void func1() {
    throw new Exception("msg");
}

void main() {
    func1();
}

shows this stack frame (debug info run through cv2pdb) when intercepting
throwing exceptions:

     kernel32.dll!_RaiseException@16()  + 0x52 bytes
     test.exe!_d_throw(Object & h={...})  Line 238    C++
> 	testexe!_Dmain()  Line 7 + 0x5 bytes	C++
     test.exe!rt@dmain2@main@runMain()  + 0xb bytes    C++
     test.exe!rt@dmain2@main@runAll()  + 0xe bytes    C++
     test.exe!main(int argc=1, char * * argv=0x008a03c4)  C++
     test.exe!_mainCRTStartup()  + 0xa9 bytes    C++
     kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes

i.e. it is missing the function actually throwing the exception.

This is caused by _d_throw not having a standard stack frame.

_d_throw is defined in deh.c and should be compiled with forcing standard stack frames using option "-S":

deh.obj : src\rt\deh.c
-    $(CC) -c $(CFLAGS) src\rt\deh.c
+    $(CC) -c $(CFLAGS) -S src\rt\deh.c

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4809



--- Comment #1 from Rainer Schuetze <r.sagitario@gmx.de> 2011-10-15 01:26:26 PDT ---
The patch here is no longer valid, because deh.c has been translated to d some time back.

Instead, use this: https://github.com/D-Programming-Language/druntime/pull/80

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4809



--- Comment #2 from github-bugzilla@puremagic.com 2012-07-08 13:51:50 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/80625a2fc87a830aa538f2f58579019c661ceac9 Merge pull request #80 from rainers/issue4809

Issue 4809: Help the stack walker to find the location of a throw statement

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4809



--- Comment #3 from github-bugzilla@puremagic.com 2012-07-22 21:24:32 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/dcc5a08e8b4ac9de869d727ceea3d407c7f92d00 Revert "Merge pull request #80 from rainers/issue4809"

This reverts commit 80625a2fc87a830aa538f2f58579019c661ceac9, reversing changes made to ce783fff516d21c253edfecb40982c833add3e4b.

https://github.com/D-Programming-Language/druntime/commit/0baa13d9df06b0a27e9b8004ecdd5e8ef338adae fix Issue 4809

- set up a stackframe for _d_throwc so that
  the caller is listed in the trace

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