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?
Created attachment 134067 [details] PATCH: Stop apps which open, close and then open alut again from crashing
Wow :) Thanks for this bugreport. I will patch our openal asap and send the patch upstream :)
Thanks again. Pushed for devel... rest will follow. I will submit it to the openal ml later today.