Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-1023

[Windows] Don't use implicit TLS variables in stdcxx library

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
    • 4.2.2
    • Thread Safety
    • None
    • Windows

    • Incorrect Behavior

    Description

      From MSDN:

      The Visual C++ compiler supports a syntax that enables you to declare thread-local variables:
      _declspec(thread). If you use this syntax in a DLL, you will not be able to load the DLL
      explicitly using LoadLibrary on versions of Windows prior to Windows Vista. If your DLL will be
      loaded explicitly, you must use the thread local storage functions instead of _declspec(thread).
      

      Personally, I've got the Access Violation Exception during performing Boost.Python regression tests, since python.exe process loading the DLL using LoadLibrary() function.

      Since the user could make own DLL, linked against stdcxx statically or dynamically, and load this DLL using LoadLibrary() function, we should not use the implicit TLS in stdcxx library to avoid such problems. If we want use thread local variables in stdcxx, we should use TlsAlloc()/TlsFree()/TlsGetValue()/TlsSetValue() functions on Windows.

      Attachments

        Activity

          People

            farid Farid Zaripov
            farid Farid Zaripov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: