[Issue 13646] New: static darray & pointer initializers always allocated in shared(global) memory rather than in TLS

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 22 01:29:16 PDT 2014


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

          Issue ID: 13646
           Summary: static darray & pointer initializers always allocated
                    in shared(global) memory rather than in TLS
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: floating.point at rambler.ru

import std.stdio, std.parallelism;

int[] buf = [1]; // int* buf = [1];

void main(){
    writeln("tls var addr = ", &buf,", ptr = ", buf.ptr, ", value = ", buf[0],"
in main before");

    auto task = task!fun();
    task.executeInNewThread();
    task.yieldForce();

    writeln("tls var addr = ", &buf,", ptr = ", buf.ptr, ", value = ", buf[0],"
in main after");
}
void fun ()  {
    writeln("tls var addr = ", &buf,", ptr = ", buf.ptr, ", value = ", buf[0],"
in child before");
    buf[0] = 2;
    writeln("tls var addr = ", &buf,", ptr = ", buf.ptr, ", value = ", buf[0],"
in child after");
}

produce output:
tls var addr = 1B21A0, ptr = 425080, value = 1 in main before
tls var addr = 1C93E8, ptr = 425080, value = 1 in child before
tls var addr = 1C93E8, ptr = 425080, value = 2 in child after
tls var addr = 1B21A0, ptr = 425080, value = 2 in main after

where 2 independent variables points to same global data

--


More information about the Digitalmars-d-bugs mailing list