www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18815] New: thread_attachThis crash


          Issue ID: 18815
           Summary: thread_attachThis crash
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

C++ main()
call rt_init
create thread (using C++11 std::thread)
from thread_entry_func:
   call into D code (via extern(C) function)
   call thread_attachThis to register the C++ thread with druntime

It appears to invoke a GC collect in thread_attachThis(), which calls
thread_suspendAll(), which calls Thread.getThis(), which returns null (because
thread_attachThis hasn't finished), which is passed to suspend(), where it is
de-referenced and segfault.

Crashes every time. Every call to thread_attachThis() without fail.

May 01 2018