← Back to index
|
Original Bugzilla link
Bug 16594 – module destructors called again if an exception got thrown earlier
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-10-04T23:10:00Z
Last change time
2016-10-09T17:10:22Z
Keywords
pull
Assigned to
nobody
Creator
code
Comments
Comment #0
by code — 2016-10-04T23:10:04Z
cat > bug.d << CODE import core.stdc.stdio; __gshared int count; shared static ~this() { printf("dtor call %d\n", ++count); if (count == 1) throw new Exception("dtor exception"); } CODE dmd -main -run bug ----
[email protected]
(8): dtor exception ---------------- ??:? void bug._sharedStaticDtor1() [0x42792a] ??:? void bug.__modshareddtor() [0x427940] ??:? void rt.minfo.__T17runModuleFuncsRevS442rt5minfo11ModuleGroup8runDtorsMFZ9__lambda1Z.runModuleFuncsRev(const(immutable(object.ModuleInfo)*)[]) [0x42db3e] ??:? void rt.minfo.ModuleGroup.runDtors() [0x42d5ac] ??:? int rt.minfo.rt_moduleDtor().__foreachbody1(ref rt.sections_elf_shared.DSO) [0x42d8f3] ??:? int rt.sections_elf_shared.DSO.opApplyReverse(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x42dcee] ??:? rt_moduleDtor [0x42d8d2] ??:? rt_term [0x42b27e] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x427fc8] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x427f48] ??:? _d_run_main [0x427eb9] ??:? main [0x427a4d] ??:? __libc_start_main [0xf6eef730] dtor call 1 dtor call 2 ----
Comment #1
by code — 2016-10-04T23:48:35Z
https://github.com/dlang/druntime/pull/1665
Comment #2
by github-bugzilla — 2016-10-07T15:51:59Z
Commits pushed to stable at
https://github.com/dlang/druntime
https://github.com/dlang/druntime/commit/20f84a3fd96859da98291f34107065b876a4ce6c
fix Issue 16594 - static dtors called twice w/ exception - must call finiSections when an exception is thrown in a destructor - marks runtime as shut down, so final unloading of executable doesn't try to run module dtors again
https://github.com/dlang/druntime/commit/a9102475cfe169a7fac2c6ce2494f5a272765b21
Merge pull request #1665 from MartinNowak/fix16594 fix Issue 16594 - static dtors called twice w/ exception
Comment #3
by github-bugzilla — 2016-10-09T17:10:22Z
Commits pushed to master at
https://github.com/dlang/druntime
https://github.com/dlang/druntime/commit/20f84a3fd96859da98291f34107065b876a4ce6c
fix Issue 16594 - static dtors called twice w/ exception
https://github.com/dlang/druntime/commit/a9102475cfe169a7fac2c6ce2494f5a272765b21
Merge pull request #1665 from MartinNowak/fix16594