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 2870

Summary: Deadlock in SDL SIGINT and SIGTERM handling
Product: SDL Reporter: Magnus Bjerke Vik <mbvett>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: mbvett
Version: 2.0.3   
Hardware: x86_64   
OS: Linux   
Attachments: Backtrace for deadlock
Code to reproduce deadlock

Description Magnus Bjerke Vik 2015-02-07 10:20:26 UTC
Created attachment 2023 [details]
Backtrace for deadlock

Receiving a SIGINT or SIGTERM while already inside malloc routines will cause the program to deadlock.

I've attached a backtrace from a case where the signal is received while freeing some allocated data.

I've also attached a simple program to reproduce the problem. It might have to be run a few times to ensure that the signal is received while in a malloc routine.

I've only tested this on Linux, yet. A simple workaround is to handle the signals yourself and avoid any malloc routines.
Comment 1 Magnus Bjerke Vik 2015-02-07 10:24:13 UTC
Created attachment 2024 [details]
Code to reproduce deadlock

You might have to run the program a few times so that the signal is received while in a malloc routine. You can also increase the numAllocs.
Comment 2 Ryan C. Gordon 2015-06-08 05:53:49 UTC
This is fixed now in https://hg.libsdl.org/SDL/rev/fd60d77139fc, thanks!

--ryan.