[Bug 35176] New: Thread-local storage not correctly initialised for explicitly-loaded DLLs

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Dec 19 11:43:54 CST 2013


http://bugs.winehq.org/show_bug.cgi?id=35176

            Bug ID: 35176
           Summary: Thread-local storage not correctly initialised for
                    explicitly-loaded DLLs
           Product: Wine
           Version: 1.7.6
          Hardware: x86
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ntdll
          Assignee: wine-bugs at winehq.org
          Reporter: r.hayden at gmail.com
    Classification: Unclassified

I came across this trying to get Microsoft Visual Studio 11.0 (2012)'s C/C++
compiler to work under wine (cl.exe). There is an already a bug report for
this:

http://bugs.winehq.org/show_bug.cgi?id=33546

The symptom is that it page faults when trying to compile even the simplest of
programs. Some investigation detailed in that bug report tracked it down to a
particular memset causing a heap corruption.

I've investigated this further and discovered that it's due to wine not
properly handling ".tls" sections in DLLs. My understanding is that this DLL
section specifies initial values for thread-local variables and should be used
to initialise these variables when new threads are created. One reason these
come about is if the _declspec(thread) syntax is used to specify thread-local
variables. It seems Wine has similar behaviour to Windows Server 2003 and
Windows XP (see the paragraph near the bottom of
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175.aspx) in that
these sections are not treated correctly for explictly-loaded DLLs, that is,
loaded using LoadLibrary, but implicitly-loaded ones are fine.

I am able to work around my particular issues with cl.exe in Visual Studio 11.0
by hacking wine to inject the DLL with the .tls section, c2.dll, when it loads
cl.exe, rather than letting it load it explicitly later on. Then it works fine
in my fairly extensive testing (compiling a very large codebase).

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list