Gc collects trigger access violation exception

mashomee via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 10 19:21:29 PST 2017


Hi, everyone.

I have a thread running in Dll. But it always halts because of 
access violation exception when GC begins collecting.

This is the thread stack frame in vs2013.

>testSendSms.exe!_D4core6thread6Thread9isRunningMFNbNdZb() + 0x1 
>bytes	D
>testSendSms.exe!_D2gc4impl12conservative2gc3Gcx10smallAllocMFNbhKkkZPv() + 0x2a6 bytes	D  testSendSms.exe!_D2gc4impl12conservative2gc14ConservativeGC6qallocMFNbkkxC8TypeInfoZS4core6memory8BlkInfo_() + 0x6d bytes	D

then found these in core.thread.d

private bool suspend( Thread t ) nothrow
{
     .........

     version( Windows )
     {
         if( t.m_addr != GetCurrentThreadId() && SuspendThread( 
t.m_hndl ) == 0xFFFFFFFF )
         {
             if( !t.isRunning )
             {
                 Thread.remove( t );
                 return false;
             }
             onThreadError( "Unable to suspend thread" );
         }
     .......
     }
     ........
  }
I think the problem is when GC detects if the threading is 
runnig, using core.thread.isRunning, the thread pointer is null.

When dll is loaded, it calls  Runtime.initialize(), 
gc_setProxy(gc) as the wiki says, so I have no idea why this 
happened, and how to fix it. Could someone give me a hint ?

Thanks!


More information about the Digitalmars-d-learn mailing list