[Issue 23859] New: [REG 2.103] Throwing while in a deep callstack causes memory corruption

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 25 05:35:49 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23859

          Issue ID: 23859
           Summary: [REG 2.103] Throwing while in a deep callstack causes
                    memory corruption
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

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.

--


More information about the Digitalmars-d-bugs mailing list