Bug 23859 – [REG 2.103] Throwing while in a deep callstack causes memory corruption
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2023-04-25T05:35:49Z
Last change time
2023-05-01T19:33:44Z
Keywords
pull
Assigned to
No Owner
Creator
Rainer Schuetze
Comments
Comment #0 by r.sagitario — 2023-04-25T05:35:49Z
When compiling this snippet
module test;
void* recurse(int n)
{
if (n > 0)
return recurse(n - 1) + 1; // avoid tail call optimization
throw new Exception("cancel");
}
void main()
{
try
{
recurse(200);
}
catch(Exception e)
{
}
}
with dmd 2.103.0 and running it on Windows with
> dmd -m64 test.d
> test.exe
> echo %errorlevel%
-1073740940
The exit code is 0xC0000374 and reports a critical error, a heap corruption in this case.
Comment #1 by dlang-bot — 2023-04-25T05:50:23Z
@rainers created dlang/dmd pull request #15127 "fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption" fixing this issue:
- fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption
avoid writing beyond the end of the trace buffer
https://github.com/dlang/dmd/pull/15127
Comment #2 by dlang-bot — 2023-04-25T19:32:23Z
dlang/dmd pull request #15127 "fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption" was merged into stable:
- a29d431b9fad6af7b5b1549a023c8599d835523e by Rainer Schuetze:
fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption
avoid writing beyond the end of the trace buffer
https://github.com/dlang/dmd/pull/15127
Comment #3 by dlang-bot — 2023-05-01T19:33:44Z
dlang/dmd pull request #15156 "merge stable" was merged into master:
- ca016bd979a479c47942c2a472d62dc03bfe21a2 by Rainer Schuetze:
fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption (#15127)
avoid writing beyond the end of the trace buffer
https://github.com/dlang/dmd/pull/15156