You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering a hard crash (segfault) when using thread-local storage (TLS) in shared libraries (DLLs) built with TDM-GCC
and consumed from executables built with MSVC. This seems to only affect TDM-GCC: libraries built with MinGW-w64 don't have the issue. This is reproducible with the latest 64-bit release of TDM-GCC, 9.2.0, and the second-latest release, 5.1.0-2. I haven't tried any 32-bit targets.
The issue manifests itself when simply accessing (reading or writing) a TLS variable:
However, there are much more subtle ways of provoking the issue, because a number of libraries – notably, pthreads – rely on TLS. For example, pthread_self(3) will hard crash. Surprising behaviour from a function whose documentation boldly states
main.c is about as small as it can be. The core of tls.c is lines 22–29; everything else is there to enable compilation under both MSVC and GCC. The Makefile mostly helps keep compiler flags and output filenames straight.
To build and reproduce, you'll need to have installed:
To isolate this to TDM-GCC, I've tried a variety of different toolchains. This failure seems to be particular to TDM-GCC, and not to the latest version.
DLL ↓/EXE →
MSVC
TDM-GCC-64 5.1.0-2
TDM-GCC-64 9.2.0
MinGW-w64 ??? (GCC 8.1.0)
MinGW-w64 5.0.3 (GCC 7.3.0), Ubuntu host
MSVC
✓
✓
✓
✓
✓
TDM-GCC-64 5.1.0-2
✗
✓
✓
✓
✓
TDM-GCC-64 9.2.0
✗
✓
✓
✓
✓
MinGW-w64 ??? (GCC 8.1.0)*
✓
✓
✓
✓
✓
MinGW-w64 5.0.3 (GCC 7.3.0), Ubuntu host
✓
✓
✓
✓
✓
* This was installed from x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z. MinGW and GCC version numbers don't seem to line up, so I'm not sure what MinGW version this would be.
The text was updated successfully, but these errors were encountered:
I'm encountering a hard crash (segfault) when using thread-local storage (TLS) in shared libraries (DLLs) built with TDM-GCC
and consumed from executables built with MSVC. This seems to only affect TDM-GCC: libraries built with MinGW-w64 don't have the issue. This is reproducible with the latest 64-bit release of TDM-GCC, 9.2.0, and the second-latest release, 5.1.0-2. I haven't tried any 32-bit targets.
The issue manifests itself when simply accessing (reading or writing) a TLS variable:
However, there are much more subtle ways of provoking the issue, because a number of libraries – notably, pthreads – rely on TLS. For example,
pthread_self(3)
will hard crash. Surprising behaviour from a function whose documentation boldly statesReproduction
Reproduction code is here: tlscrash.tar.gz.
main.c
is about as small as it can be. The core oftls.c
is lines 22–29; everything else is there to enable compilation under both MSVC and GCC. TheMakefile
mostly helps keep compiler flags and output filenames straight.To build and reproduce, you'll need to have installed:
Launch the “x64 Native Tools Command Prompt for VS 2019” to get a command-line environment where MSVC will work. Then:
If you have any other toolchains installed, you can compile with those for comparison, too:
The
main
executables expect one argument: the name of the library to load.Expected success:
Expected failure:
Or, in a MSYS2 environment (e.g., Git Bash):
Toolchains tested
To isolate this to TDM-GCC, I've tried a variety of different toolchains. This failure seems to be particular to TDM-GCC, and not to the latest version.
* This was installed from
x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z
. MinGW and GCC version numbers don't seem to line up, so I'm not sure what MinGW version this would be.The text was updated successfully, but these errors were encountered: