Bug 15894 – Allow setting of rt_trapExceptions from module c'tors

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2016-04-07T19:42:20Z
Last change time
2019-08-30T16:02:04Z
Assigned to
No Owner
Creator
Marenz
See also
https://issues.dlang.org/show_bug.cgi?id=4385

Comments

Comment #0 by dmdtracker — 2016-04-07T19:42:20Z
If you want a proper core dump upon an assert failure (or generally a uncaught exception), you have to set rt_trapExceptions to 0. You can't do that however without either compiling your own runtime or attaching a debugger and setting it from there before main() is called. While you can change the variable (as it is a global extern (C), your change has no effect because all user code is run only after the variable has been read. This PR changes the behavior so that changes to that variable done from a module c'tor will cause your main() to be called without the exception trap: https://github.com/D-Programming-Language/druntime/pull/1538
Comment #1 by leandro.lucarella — 2016-04-08T14:46:24Z
What about making it a runtime option a la `--DRT-trap-exceptions`?
Comment #2 by dmdtracker — 2016-04-08T14:50:38Z
I have nothing against it, but right now I try to propose as little change as possible to increase the chances of this getting actually merged.
Comment #3 by 4burgos — 2016-10-19T09:04:04Z
Comment #4 by r.sagitario — 2019-08-30T16:02:04Z
Implemented via #18220 as --DRT-trapExceptions=0. Exception trapping cannot be enabled if running in a debugger under windows, but not sure if that is a troublesome restriction. *** This issue has been marked as a duplicate of issue 18220 ***