Crash on sound destroy

DenisKoronchik

18-03-2013 15:44:17

Has compiled under OSX 10.8.2 and take a crash.
Before that this code works on older versions. This code works on Windows, iOS. But crashes on OSX.
Has found why.

Problem is in OgreOggStaticWavSound::setSource function (possible for other implementations of sounds). It calls twicely on destroy.
First:

/*/////////////////////////////////////////////////////////////////*/
bool OgreOggSoundManager::_releaseSoundSource(OgreOggISound* sound)
{
if (!sound) return false;

if (sound->getSource()==AL_NONE) return true;

// Get source
ALuint src = sound->getSource();

// Valid source?
if(src!=AL_NONE)
{
ALuint source=AL_NONE;

// Detach source from sound
sound->setSource(source);
....


And sound source setup to 0 value.
After that calls

/*/////////////////////////////////////////////////////////////////*/
void OgreOggSoundManager::_releaseSoundImpl(OgreOggISound* sound)
{
...
// Delete sound
OGRE_DELETE_T(sound, OgreOggISound, Ogre::MEMCATEGORY_GENERAL);
}


That calls destructor of sound object, where calls function _relase

void OgreOggStaticWavSound::_release()
{
ALuint src=AL_NONE;
setSource(src);
OgreOggSoundManager::getSingleton()._releaseSharedBuffer(mAudioName, mBuffer);
mPlayPosChanged = false;
mPlayPos = 0.f;
}

That calls setSource with 0 parameter second time. Where i'm getting crash under OSX in lines

// Need to stop sound BEFORE unqueuing
alSourceStop(mSource);


So need to fix that error, because OpenAL implementation for latest OSX possible raise exception, when trying to stop 0 source.

Gdlk

21-03-2013 15:00:36

Wow! fixing that it could solve the double free crash ( i hope it ).

Denis, how do you setup your code to find that?? (I know is a off topic question, but i am really interest in learn to find things like that. I use gdb and valgrind, but I cant set the ogreOggSound code in my project to start finding things like that (I only can set the plugin... so i cant get useful debugging information with gdb or memory leaks detection with valgrind, so i dont succeed to get a starting point to begin looking/route the problem...) ). Any advice/page/book/other would be great =)

Thanks in advance!

Regards!!

DenisKoronchik

25-03-2013 09:24:22

Wow! fixing that it could solve the double free crash ( i hope it ).

Denis, how do you setup your code to find that?? (I know is a off topic question, but i am really interest in learn to find things like that. I use gdb and valgrind, but I cant set the ogreOggSound code in my project to start finding things like that (I only can set the plugin... so i cant get useful debugging information with gdb or memory leaks detection with valgrind, so i dont succeed to get a starting point to begin looking/route the problem...) ). Any advice/page/book/other would be great =)

Thanks in advance!

Regards!!


I'm use source code of OgreOggSound in my project and build it as library. So I can debug it in runtime. All errors i've found in debugging with breakpoints. For example, I spent 9 hours to find error http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=29797 :)

stickymango

26-03-2013 00:40:33

Hi,

Thanks for the heads up, how did you produce this error?

Regards,

DenisKoronchik

26-03-2013 12:10:16

Hi,

Thanks for the heads up, how did you produce this error?

Regards,


If you ask about this one (viewtopic.php?f=19&t=29797), then i can answer your question.
I've just take feedback from game developer, that the game crashes, then i've made test, where starts randomly sounds (about 5-20 per second), so i've produce this error.

Gdlk

28-03-2013 02:28:19

Wow! fixing that it could solve the double free crash ( i hope it ).

Denis, how do you setup your code to find that?? (I know is a off topic question, but i am really interest in learn to find things like that. I use gdb and valgrind, but I cant set the ogreOggSound code in my project to start finding things like that (I only can set the plugin... so i cant get useful debugging information with gdb or memory leaks detection with valgrind, so i dont succeed to get a starting point to begin looking/route the problem...) ). Any advice/page/book/other would be great =)

Thanks in advance!

Regards!!


I'm use source code of OgreOggSound in my project and build it as library. So I can debug it in runtime. All errors i've found in debugging with breakpoints. For example, I spent 9 hours to find error http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=29797 :)


ok! thanks!! =)

stickymango

02-04-2013 10:43:12

Fix has been committed for this issue, it only affected static sounds, streamed sounds already checked for this condition.

Thanks for the find!!