www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2491] New: druntime GC wrongly frees data pointed to by TLS.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2491

           Summary: druntime GC wrongly frees data pointed to by TLS.
           Product: D
           Version: 2.021
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


Apparently, under certain circumstances, the D 2.21 druntime GC wrongly frees
memory locations pointed to by thread-local storage.

import core.memory, std.stdio;

__thread Stuff* stuff1;

struct Stuff {
    uint num;
}

void main() {
    stuff1 = new Stuff;
    stuff1.num = 1;
    auto bar = new byte[1024 * 1024];
    auto stuff2 = new Stuff;
    stuff2.num = 2;
    writeln(stuff1, "\t", stuff2);  // Same address.
    writeln(stuff1.num, "\t", stuff2.num);  // Both 2.
}

If you disable the GC using GC.disable at the top of main() or change stuff1 to
a non-thread-local, the problem goes away.


-- 
Dec 05 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2491


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 2.022


-- 
Dec 25 2008