[
https://issues.apache.org/jira/browse/QPID-1868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743471#action_12743471
]
Steve Huston commented on QPID-1868:
------------------------------------
The AsynchIO.cpp stats are removed in SVN trunk r804394. Just the
ManagementObject.cpp one is left.
> Implicit TLS variables in AsyncIO can cause access violation when dynamically
> loading qpidcommon and qpidclient DLLs
> --------------------------------------------------------------------------------------------------------------------
>
> Key: QPID-1868
> URL: https://issues.apache.org/jira/browse/QPID-1868
> Project: Qpid
> Issue Type: Bug
> Components: C++ Client
> Affects Versions: 0.5
> Environment: Windows XP w/SP3
> Visual Studio 2005
> Reporter: David Rennalls
> Attachments: AsyncIO_TLS.patch, patch.txt
>
>
> src/qpid/sys/windows/AsynchIO.cpp is using some implicit thread local storage
> variables. If the qpid DLLs are dynamically loaded (or another DLL that
> statically links in qpid) no space will be allocated for the TLS data. So if
> client code tries to access one of the TLS variables defined in AsyncIO.cpp
> it will get an access violation. Taken from [1]...
> "..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 of 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..."
> ...[2] also warns against this..
> "Windows Server 2003 and Windows XP: 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)."
> I ran into this when my DLL that links in qpid client and common libs
> statically is loaded dynamically by a python wrapper, the first access to the
> one of the TLS variables cause a crash. For reference , [3] (part 1 of 8) has
> a good overview of TLS on Windows, and implicit vs explicit TLS
> [1] http://msdn.microsoft.com/en-us/library/2s9wt68x(vs.71).aspx - Rules and
> Limitations for TLS
> [2] http://msdn.microsoft.com/en-us/library/ms684175.aspx - LoadLibrary
> function
> [3] http://www.nynaeve.net/?p=180 - Thread Local Storage, part 1: Overview
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]