Bug 19231 – Infinite loop in exception chains

Status
NEW
Severity
minor
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-09-06T17:09:59Z
Last change time
2024-12-07T13:38:35Z
Assigned to
No Owner
Creator
Neia Neutuladh
Moved to GitHub: dmd#17370 →

Comments

Comment #0 by dhasenan — 2018-09-06T17:09:59Z
void throwy() { auto e = new Exception("root"); scope (exit) throw new Exception("scope 1", e); throw e; } void main() { throwy(); } This results in an infinite loop in druntime. There are only two exceptions, but because they form a loop instead of a proper linked list, druntime keeps on printing them. Perhaps we should define a reasonable limit on the number of exceptions we print before quitting out. 10 should probably be plenty.
Comment #1 by schveiguy — 2018-09-06T18:06:37Z
There are 2 options other than adding just a limit. First, we could use tortoise and hare algorithm to detect the cycle. Second, we could mark each exception somehow as it is printed, and then unmark them after the printing algorithm is over.
Comment #2 by robert.schadek — 2024-12-07T13:38:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17370 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB