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

sound: crash in Sound_Rewind after SDL_sound replacement of libvorbisfile #9

Open
JanSimek opened this issue Jan 15, 2014 · 5 comments

Comments

@JanSimek
Copy link
Contributor

I had to revert Alex Richardson's commit 17267f6 in my fork due to the crash that it introduced in sound/openal/SoundLib.cpp

#0  0x00000001019ff550 in Sound_Rewind ()
#1  0x000000010074fa1c in sfx::SoundStream::stop (this=0x10204c7e0) at /Users/jansimek/Development/shadowgrounds/sound/openal/SoundLib.cpp:1101
#2  0x000000010073a636 in sfx::SoundMixer::Data::updateMusic (this=0x112e1ea30, delta=16) at /Users/jansimek/Development/shadowgrounds/sound/SoundMixer.cpp:629
#3  0x00000001007356c1 in sfx::SoundMixer::runMixer (this=0x102330950, currentTime=17879) at /Users/jansimek/Development/shadowgrounds/sound/SoundMixer.cpp:905
#4  0x00000001000bcf89 in game::GameUI::runUI (this=0x1020696c0, currentTime=17879) at /Users/jansimek/Development/shadowgrounds/game/GameUI.cpp:2260
#5  0x000000010001310b in SDL_main (argc=4, argv=0x105000000) at /Users/jansimek/Development/shadowgrounds/shadowgrounds/shadowgrounds.cpp:1193

Happens at various times. For example, at the beginning of the 4th act during the intro cinematics when the alien is looking through his binoculars at Wesley and Jane entering the communications facility.

@arichardson
Copy link

Interesting, as far as I can remember it did not work properly for me before using SDL_Sound.

Could it maybe be a NULL pointer dereference? Does it still crash if you replace

if (Sound_Rewind(data->sdlSample) != 0) {
  LOG_ERROR(strPrintf("Failed to rewind: %s\n", Sound_GetError()).c_str());
}

with

if (data->sdlSample && Sound_Rewind(data->sdlSample) != 0) {
  LOG_ERROR(strPrintf("Failed to rewind: %s\n", Sound_GetError()).c_str());
}

Any chance of checking with a debug + source build of SDL where that crash happens exactly?

@JanSimek
Copy link
Contributor Author

Yes, I already tried if (data->sdlSample) {... but it did not change anything and there was the same crash in Sound_Rewind. I will try tomorrow on linux and if it fails, I will try to compile debug build of SDL.

@vayerx
Copy link
Owner

vayerx commented Jan 16, 2014

Jan, does it happen in both Shadowgrounds and S.Survivor?
Please could you run the game with valgrind --track-origins=yes -- maybe sound buffer is freed or its pointer is overwritten somewhere.

@vayerx
Copy link
Owner

vayerx commented Jan 19, 2014

I confirm crash in Sound_Rewind. Segmentation fault occurs at the first access to sample (invalid pointer):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5267a77 in Sound_Rewind (sample=0x4342000043f98000) at SDL_sound.c:870
870     internal = (Sound_SampleInternal *) sample->opaque;

#0  0x00007ffff5267a77 in Sound_Rewind (sample=0x4342000043f98000) at SDL_sound.c:870
#1  0x0000000000c06a51 in sfx::SoundStream::stop (this=0xfcf6330) at shadowgrounds/sound/openal/SoundLib.cpp:1095
#2  0x0000000000bf9e3c in sfx::SoundMixer::stopStreamedSounds (this=0x1ed9db0) at shadowgrounds/sound/SoundMixer.cpp:983
#3  0x000000000081dff5 in game::GameUI::stopAllStreamedSounds (this=0x2221950) at shadowgrounds/game/GameUI.cpp:6528
#4  0x0000000000a025a1 in game::SoundScripting::process (sp=0x10e5f860, command=1843, intFloat=..., stringData=0x0, lastValue=0x10e5f864, gsd=0x10e5f7a0, game=0x21e2a50)
    at shadowgrounds/game/scripting/SoundScripting.cpp:85
#5  0x00000000008a7132 in game::GameScripting::process (this=0x16de8b0, sp=0x10e5f860, command=1843, intFloat=..., stringData=0x0, lastValue=0x10e5f864)
    at shadowgrounds/game/scripting/GameScripting.cpp:167
#6  0x0000000000baa7b6 in util::Script::run (this=0x5d092c0, sp=0x10e5f860, pausable=false) at shadowgrounds/util/Script.cpp:1644
#7  0x00000000008a780a in game::GameScripting::runScriptProcess (this=0x16de8b0, sp=0x10e5f860, pausable=false) at shadowgrounds/game/scripting/GameScripting.cpp:342
#8  0x00000000007e8280 in game::Game::run (this=0x21e2a50) at shadowgrounds/game/Game.cpp:1236
int Sound_Rewind(Sound_Sample *sample)
{
    Sound_SampleInternal *internal;
    BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);

    internal = (Sound_SampleInternal *) sample->opaque;
    if (!internal->funcs->rewind(sample))
    {
        sample->flags |= SOUND_SAMPLEFLAG_ERROR;
        return(0);
    } /* if */

@ghost ghost assigned vayerx Jan 19, 2014
vayerx added a commit that referenced this issue Feb 4, 2014
@vayerx
Copy link
Owner

vayerx commented Feb 4, 2014

I had no time to look at the problem so I decided to reverted commit 17267f6 for now -- it's better to have unbroken main branch. I'll return to it later.

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

No branches or pull requests

3 participants