Bug 15190 – scope(success/failure) are oddly implemented and mask stack traces

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-11T20:32:53Z
Last change time
2024-12-13T18:45:17Z
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#19057 →

Attachments

IDFilenameSummaryContent-TypeSize
1558test.dDemonstration programapplication/x-dsrc877

Comments

Comment #0 by dlang-bugzilla — 2015-10-11T20:32:53Z
Created attachment 1558 Demonstration program scope statements seem to be rethrowing exceptions, or otherwise causing them to be (re)thrown them from within the stack frame of the function containing the scope statement, and not the function where the exception was thrown. This causes loss of information on the exception's origin, which makes debugging difficult. This is especially severe when the exception does not itself contain a stack trace (e.g. it's an OutOfMemoryError or an InvalidMemoryOperationError). I'm attaching a demonstration program. To reproduce the issue, compile the program (and specify one of the defined versions), start it under gdb and run "break _d_throwc", "run" and "where". Depending on the version specified, the f!int function invocations will or will not be visible in the stack trace displayed by gdb. Here are my results (Linux, DMD64 v2.068.1, gdb 7.7.1): Version | f!int visible? | Description --------+----------------+-------------------- test0 | Yes | No scope/try blocks testSS | No | scope(success) testSF | No | scope(failure) testSX | Yes | scope(exit) testTN | Yes | try/catch testTF | Yes | try/finally From what was tested, only scope(success) and scope(failure) rethrew the exception from main(). Things of note: 1. As far as I can see, scope(success) has no reason to interfere with exceptions at all, all it should do is virtually insert code before every return point in the function. 2. scope(exit) displays the full stack trace, despite that it is simply the union of scope(success) and scope(failure).
Comment #1 by robert.schadek — 2024-12-13T18:45:17Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19057 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB