Bug 202260 - PATCH: Stop apps which open, close and then open alut again from crashing
PATCH: Stop apps which open, close and then open alut again from crashing
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: openal (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Andreas Bierfert
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-11 16:34 EDT by Hans de Goede
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-21 03:33:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Hans de Goede 2006-08-11 16:34:20 EDT
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 16:34:21 EDT
Created attachment 134067 [details]
PATCH: Stop apps which open, close and then open alut again from crashing
Comment 2 Andreas Bierfert 2006-08-12 05:17:47 EDT
Wow :) Thanks for this bugreport. I will patch our openal asap and send the
patch upstream :)
Comment 3 Andreas Bierfert 2006-08-21 03:33:40 EDT
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.