Cannot get thread ID with Thread.getThis() in specific callback functions on Windows
Haruki Shigemori
rayerd.wiz at gmail.com
Thu Dec 9 12:38:47 PST 2010
(2010/12/10 5:14), Rainer Schuetze wrote:
>
> A DLL gets notified in its entrypoint DllMain about new threads. When it
> receives such a notification, it mainly does the following:
>
> if( !thread_findByAddr( GetCurrentThreadId() ) )
> thread_attachThis();
> if( !_moduleinfo_tlsdtors_i ) // avoid duplicate calls
> _moduleTlsCtor();
>
> You might want to try inserting this snippet into your callback.
>
> Rainer
Thank you!
$ type a.d
import win32.windows;
import win32.mmsystem;
import std.stdio;
import core.thread;
extern (Windows)
void waveInProc(in HWAVEIN handle, in uint message, in DWORD instance,
in DWORD param1, in DWORD param2)
{
if( !thread_findByAddr( GetCurrentThreadId() ) )
thread_attachThis();
if( !_moduleinfo_tlsdtors_i ) // avoid duplicate calls
_moduleTlsCtor();
int[] a;
int[] b = a.dup;
}
...
$ bud a /Ldetailedmap -g -full
...
$ ddbg a
-> r
...
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
gc.gcx.Gcx.__invariant src\gc\gcx.d:1553 (0x0041e507) thread(6136)
->q
Ummm...?
More information about the Digitalmars-d
mailing list