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 2814 - Crash behaviour caused by conflict between SDL_DrawRect and SDL_Mixer
Summary: Crash behaviour caused by conflict between SDL_DrawRect and SDL_Mixer
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.3
Hardware: x86 Windows (XP)
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-11 01:01 UTC by mattreecebentley
Modified: 2016-01-22 03:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mattreecebentley 2014-12-11 01:01:51 UTC
I don't know if this is SDL_Mixer's fault or SDL_DrawRect, but:
upon stress-testing my new game engine, I found I can very easily crash the program (randomly but repeatedly) by running a high number of SDL_DrawRect calls at the same time as playing a lot of sounds using SDL_Mixer.

The situation can occur with a smaller number of sounds being played back simultaneously, but can be almost insta-crashed with a high number of sounds.

With straight texture blits and no SDL_DrawRect calls, the program will not crash.
With SDL_DrawRect calls and no SDL_Mixer calls, the program will not crash.

Only when both SDL_DrawRect and SDL_Mixer calls are made, will the program crash.

When it crashes, it either crashes in:
(a) An undefined space
(b) upon the SDL_DrawRect call
(c) in an undefined space with references to either SDL2_mixer!Mix_SetReverseStereo, or SDL2_mixer!Mix_SetVolume, or both.

When it crashes codelite (my IDE) always opens 'new' ie. The -*- C++ -*- dynamic memory management header, and the final part of the backtrace is always SDL_LogCritical. Routing SDL_Log to a file gives no output from LogCritical.

There is no multithreading in the app. For each SDL_Mixer sound playback, there is typically a 	Mix_Volume(current_channel, current_volume) or 	Mix_SetPanning(current_channel, 255 - current_pan, current_pan), with it.

There are no links whatsoever between the class doing the SDL_DrawRect call and the class doing the SDL_Mixer calls. They are completely separate (one's a quadtree, the other a sound library).

I've triple-checked both modules and sections of code, and there's no issues there. The issues only show up when both DrawRect and SDL_Mixer functions are called.

Though the crash can sometimes occur with 60-or-so sounds in playback and a smaller number of SDL_Rect calls, I can nearly insta-crash it with a high number eg. 2000 sounds + > 2000 DrawRects per frame. Removing either the sounds or the DrawRects removes the crash.
Comment 1 mattreecebentley 2014-12-11 01:10:53 UTC
Minor update: removing Mix_Volume and Mix_SetPanning calls seems to have no effect, only removing Mix_PlayChannel - so the conflict is directly between high numbers of calls to Mix_PlayChannel and SDL_DrawRect.
Comment 2 mattreecebentley 2016-01-22 03:21:22 UTC
Resolved as of SDL 2.04 - thanks!