Windows DLLs and TLS

Jakob Ovrum jakobovrum at gmail.com
Tue Oct 9 05:12:30 PDT 2012


On Tuesday, 9 October 2012 at 10:21:58 UTC, Regan Heath wrote:
> On Mon, 08 Oct 2012 19:32:40 +0100, Jakob Ovrum 
> <jakobovrum at gmail.com> wrote:
>> XChat uses gmodule - part of glib - to load plugins. I looked 
>> at gmodule's Windows implementation, and it uses LoadLibraryW.
>
> Does your dummy C host application also use gmodule to load the 
> dll.. that might be a useful experiment perhaps.
>
> R

I tried this, and the results are illuminating.

I added gmodule support to the C host, enabling switching between 
using gmodule and direct WinAPI at the switch of a preprocessor 
define.

When the WinAPI is used directly, they get their correct 
initializers like before (I included some variables with explicit 
initializers too, like void* test3 = cast(void*)1).

When gmodule is used, the test TLS variables contain garbage! The 
garbage values are different every time the program runs.

I'll look closer at what gmodule is doing.


More information about the Digitalmars-d mailing list