Hi All,

Quick update:

Last night I managed to get win32 factor to bootstrap and run on my 
linux laptop using wine and mingw32 so I can now do some windows 
portability coding. Unfortunately I'm having some problems with the 
reentrancy code, which I guess are also problems on 'real' win32 
platforms too.

After some limited testing my best guess is that thread-local-storage is 
causing problems with LoadLibrary (dlsym) loaded symbols. Internal 
variables are fine but those externally referenced in factor code 
indirectly using the rel-dlsym word (e.g. words in x86.factor) seem to 
crash the vm.

I found this on the msdn site:
http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx

  "If a DLL declares any nonlocal data or object as __declspec( thread 
), it can cause a protection fault if dynamically loaded. After the DLL 
is loaded with LoadLibrary, it causes system failure whenever the code 
references the nonlocal __declspec( thread ) data. Because the global 
variable space for a thread is allocated at run time, the size of this 
space is based on a calculation of the requirements of the application 
plus the requirements of all the DLLs that are statically linked. When 
you use LoadLibrary, there is no way to extend this space to allow for 
the thread local variables declared with __declspec( thread ). Use the 
TLS APIs, such as TlsAlloc, in your DLL to allocate TLS if the DLL might 
be loaded with LoadLibrary. "

So now I don't know whether to dick around with TlsAlloc or to wrap this 
state up in functions (which I guess would pose a performance penalty).

Also I don't know much at all about win32 programming, bit it looks like 
using TlsAlloc involves using functions (TlsSetValue, TlsGetValue) to 
get and set TLS variables, which is a bit shite:

http://msdn.microsoft.com/en-us/library/ms686997%28VS.85%29.aspx

Have I got the wrong end of the stick here? Does anybody here understand 
win32 threading a bit better than me?

Any help or ideas much appreciated,

Cheers,

Phil



------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to