Bug 202260 - PATCH: Stop apps which open, close and then open alut again from crashing
Summary: PATCH: Stop apps which open, close and then open alut again from crashing
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: openal
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Andreas Bierfert
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-11 20:34 UTC by Hans de Goede
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-08-21 07:33:40 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
PATCH: Stop apps which open, close and then open alut again from crashing (1.96 KB, patch)
2006-08-11 20:34 UTC, Hans de Goede
no flags Details | Diff

Description Hans de Goede 2006-08-11 20:34:20 UTC
I've been trying out fakenes which uses freealut and which has the (I admit
nasty) habbit of closing and reopenign alut every time a sound setting is
changed from the menus. This causes a segfault caused by a bug in openal:

If a program calls:
alutInit()
alutExit()
alutInit()

Then the calling program will crash. This is because alutExit() calls
alcMakeContextCurrent(NULL)
before calling:
alcDestroyContext()
The alcMakeContextCurrent(NULL) will set the ispaused local static variable in
alcMakeContextCurrent() to true. When alutInit gets called the second time 
it creates a new context and calls alcMakeContextCurrent() with this new
context, alcMakeContextCurrent() then tries goes into the unpause code-path
because it believes that al is currently paused. In this path
alcMakeContextCurrent() calls _alcDeviceResume( cc->write_device ), however 
since the passed context is a new one cc->write device is NULL -> segfault.

This can easily be fixed by checking that cc->write_device device is not
null before resuming it (and the same for cc->read_device). These checks are
already done in the pause path before pausing the devices but strange enough
they are missing from the unpause path.

A bigger problem is that the pause/unpause paths call
_al(Un)lockMixerPause(), however if the last context has been destroyed by 
alcDestroyContext(), then the Mixer will have been destroyed (and thus
unpaused) too, so we will be unlocking something we didn't lock. To work
around this _alTryLockMixerPause() should be called before
_alUnlockMixerPause() in the pause path so that we always have the lock
(either we already did or we got it with the _alTryLockMixerPause()) when
unlocking.

The attach patches adds both the checks and the needed _alTryLockMixerPause()
call, fixing the crashes with fakenes for me.

I assume you will take care of merging this upstream?

Comment 1 Hans de Goede 2006-08-11 20:34:21 UTC
Created attachment 134067 [details]
PATCH: Stop apps which open, close and then open alut again from crashing

Comment 2 Andreas Bierfert 2006-08-12 09:17:47 UTC
Wow :) Thanks for this bugreport. I will patch our openal asap and send the
patch upstream :)

Comment 3 Andreas Bierfert 2006-08-21 07:33:40 UTC
Thanks again. Pushed for devel... rest will follow. I will submit it to the
openal ml later today.


Note You need to log in before you can comment on or make changes to this bug.