Windows DLLs and TLS

Jakob Ovrum jakobovrum at gmail.com
Mon Oct 8 04:26:29 PDT 2012


I have a bug in one of my programs that I find particularly hard 
to reduce.

I am writing a Windows DLL plugin for the IRC chat client HexChat 
(aka XChat). Problem is, all TLS variables, regardless of type, 
appear to be initialized to complete rubbish values. Reading them 
does not cause an access violation or anything, but the initial 
values are garbage. I am initializing the runtime using the 
helpers found in core.sys.windows.dll [1].

I wrote a dummy host application in C mimicking the loading 
behaviour of HexChat - the TLS variables are initialized 
correctly in this case, even though the DLL file is exactly the 
same.

What is it that a host application can do to break the TLS of a D 
plugin it loads?

[1] http://pastebin.com/rg9uUQMe



More information about the Digitalmars-d mailing list