www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Gc collects trigger access violation exception

reply mashomee <mashomee gmail.com> writes:
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!_D2gc4impl12conservative2gc14ConservativeGC6qallocMFNbkkxC8TypeInfoZS4co
e6memory8BlkInfo_() + 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!
Feb 10
next sibling parent mashomee <mashomee gmail.com> writes:
problem solved now.
Just not use gc_setProxy.
Feb 11
prev sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Saturday, 11 February 2017 at 03:21:29 UTC, mashomee wrote:
 Hi, everyone.

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

 [...]
It's great that you're found a workaround. If you weren't doing something funky to trigger this, please file a bug report at http://issues.dlang.org
Feb 12