#38 Boehm GC uses _declspec(threads) and cannot be loaded as a plugin

HEAD
open
nobody
1
2014-09-23
2012-12-02
No

JJG> The fact that cl_boot() crashes if the program is not linked with
JJG> ecl.dll seems like a completely different thing to me and one
JJG> worth debugging.

Exactly! I've found that problem is
using __declspec(thread) in GC. Look:

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

http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx

Since I made changes from attached patch, cl_boot returns 1. No more
access violation.

thread_local_alloc.h
index 90a246a..69c90a1 100644
--- a/src/gc/include/private/thread_local_alloc.h
+++ b/src/gc/include/private/thread_local_alloc.h
@@ -34,11 +34,7 @@
!defined(USE_WIN32_COMPILER_TLS) && !defined(USE_COMPILER_TLS) && \ !defined(USE_CUSTOM_SPECIFIC)
# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
-# if defined(GNUC) / Fixed for versions past 2.95? /
# define USE_WIN32_SPECIFIC
-# else
-# define USE_WIN32_COMPILER_TLS
-# endif / !GNU /
# elif defined(LINUX) && !defined(ARM32) && \ (GNUC > 3 || (GNUC == 3 && GNUC_MINOR >=3))
# define USE_COMPILER_TLS
--

Discussion


Anonymous


Cancel   Add attachments