[Issue 20862] New: Segfault on repeated GC.qalloc calls

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 24 19:51:20 UTC 2020


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

          Issue ID: 20862
           Summary: Segfault on repeated GC.qalloc calls
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

The following code causes a segfault in the GC (tested on 2.092.0):

===================================================
void main()
{
    import core.memory;

    string[] arr;

    foreach (_; 0 .. 3) // first two iterations pass
    {
        immutable len = arr.length;

        auto bi = GC.qalloc(string.sizeof);
        arr = (cast(string*) bi.base)[0 .. len];

        arr = arr.ptr[0 .. len + 1];
        arr[] = [];
    }
}
===================================================

gdb:

Program received signal SIGSEGV, Segmentation fault.
0x0000000008067be6 in
_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbmKmkxC8TypeInfoZPv ()

--


More information about the Digitalmars-d-bugs mailing list