We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3645

Summary: Thread naming crashes GDB, "Program received signal ?, unknown signal"
Product: SDL Reporter: cremmy
Component: threadAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus
Version: 2.0.5   
Hardware: x86   
OS: Windows 7   
See Also: https://bugzilla.libsdl.org/show_bug.cgi?id=2185

Description cremmy 2017-05-11 19:32:13 UTC
This problem is present when debugging (GDB, confirmed on versions 7.6.1, 7.11 and 7.12, 32 and 64bit) program compiled unger MinGW (MinGW_w64 and TDM-GCC).
In SDL_SYS_SetupThread (/src/thread/windows/SDL_systhread.c:168) uses Windows' way of naming threads, namely raising an exception. However, many (all available?) versions of GDB don't seem to support that, and if such exception is thrown, then program crashes and GDB shows error "Program received signal ?, unknown signal".

I've confirmed that this happens when calling SDL_Init with EVERYTHING flag OR SDL_OpenAudio OR MIX_OpenAudio - using sound makes one unable to use debugger.

SDL_SYS_SetupThread function checks if SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING hint is false, if not then it returns from function. Possible workaround is to set this hint to "1" early in program.

My suggestion is to set this hint to "1" by default on MinGW builds, as it doesn't seem that GDB will support thread naming soon (this bug was supposed to be fixed in 7.11.1-1, in 7.12 it still doesn't work).
Comment 1 Ryan C. Gordon 2017-06-06 17:15:17 UTC
I've turned off the Visual Studio-style thread naming in https://hg.libsdl.org/SDL/rev/abf45a095845 ...VS users can set the hint if they want to, everyone else will carry on.

(and everything will eventually support the new Win32 SetThreadDescription() API anyhow).

--ryan.