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 2020

Summary: Race condition between SDL_PushEvent and SDL_SetEventFilter.
Product: SDL Reporter: Rainer Deyke <rainerd>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann, sezeroz, sylvain.becker
Version: HG 2.0   
Hardware: All   
OS: All   

Description Rainer Deyke 2013-08-07 11:43:49 UTC
SDL_PushEvent is supposed to be thread-safe.  However, SDL_PushEvent reads the event filter function pointer (SDL_EventOK) that is written by SDL_SetEventFilter.  This is a race condition that could lead to SDL_PushEvent reading a corrupted pointer if SDL_SetEventFilter is called in the main thread while SDL_PushEvent is called in another thread.
Comment 1 Sam Lantinga 2013-08-07 12:12:20 UTC
How does the race condition manifest in your program?
Comment 2 Philipp Wiesemann 2015-10-14 20:33:51 UTC
SDL_PushEvent() is not really thread-safe but SDL_PeepEvents() should be. If user events need to be added from another thread then SDL_PeepEvents() can be used (it does not access the filters and gestures).
Comment 3 Sylvain 2017-10-24 19:53:32 UTC
similar issue with bug 2107
Comment 4 Sylvain 2019-10-14 15:38:41 UTC
Was fixed here: https://hg.libsdl.org/SDL/rev/6d17410edb75