Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in Mix_SetPanning, Mix_SetDistance, and Mix_SetPosition #54

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.8
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2008-12-06 16:17:24 +0000, Lee Salzman wrote:

There is a race condition in Mix_SetPanning, Mix_SetDistance, and Mix_SetPosition, where it retrieves/modifies the position_args structure without calling SDL_LockAudio/SDL_Unlock audio first.

So between the call to get_position_arg(), and where it actually sets values in the position_args structure, the mix_channels callback is freeing the structure when a channel is done playing. Thus the args get modified after the struct is freed.

This leads to crashes/unstable behavior when combined the nvidia's opengl driver, due to the driver allocating structures of the same exact size (and hence tends to reuse the same memory), which SDL is modifying after glibc's malloc has handed the memory off to nvidia's opengl driver.

SDL_LockAudio() must be called before get_position_arg(), the lock kept and released via SDL_UnlockAudio() only after Mix_RegisterEffect() has been called, to correct this, in all three of these functions, i.e.

SDL_LockAudio();
...
args = get_position_arg();
...
args->... = ...;
...
Mix_Register_Effect(..., args);
...
SDL_UnlockAudio();

On 2009-09-26 02:17:19 +0000, Sam Lantinga wrote:

Ryan, can you take a look at this?

On 2009-10-10 19:59:28 +0000, Ryan C. Gordon wrote:

Fixed in svn revision # 5045.

--ryan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant