| Summary: | SDL_FreeSurface is NOT thread safe | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Dan_ru <dan_ru> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | orangepikmin333 |
| Version: | 2.0.5 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | Source of test app | ||
I ran into this issue yesterday after refactoring my surface loading logic and, after several hours of frustration, I decided that the problem probably lies in SDL itself. My surface is stored in a wrapper that calls SDL_FreeSurface, and that wrapper is stored in a smart pointer - as such, it is impossible for my program to have freed the same surface twice. Furthermore, this issue doesn't occur when I comment out SDL_FreeSurface, so I'm certain that the problem has to do with it. Has anything been done for this issue? I'm thinking I might have to just single-thread my surface loading for now. Additional info: while this issue occurred for me on Linux, I could not reproduce it on Windows. |
Created attachment 2763 [details] Source of test app Function SDL_FreeSurface() is NOT thread safe in all 2.0.X version of SDL. Versions 1.X.X is free from bug. Calling SDL_FreeSurface() on different surfaces can cause crashing ("double free"). As I see problem is in fuctions SDL_AllocFormat() and SDL_FreeFormat() - currently work with global list "static SDL_PixelFormat *formats;" is not under mutex. Also I can suggest to move calling SDL_FreeFormat() from SDL_FreeSurface() to SDL_QuitSubSystem(SDL_INIT_VIDEO) and/or SDL_Quit(). Source of test app is attched.