We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1208

Summary: SDL_mixer crashes when I try to reinitialize it when timidity is used
Product: SDL_mixer Reporter: Andrey Budko <e6y>
Component: miscAssignee: Sam Lantinga <slouken>
Status: WAITING --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P1    
Version: 1.2.11   
Hardware: x86   
OS: Windows (XP)   
Attachments: dr. watson log

Description Andrey Budko 2011-05-23 04:23:06 UTC
SDL_mixer crashes when I try to reinitialize it when timidity is used.

It happens randomly, but often.

Looks like it crashes in recompute_amp() at
refv = (double)(tempamp) * voice[v].sample->volume * master_volume;
because
voice[v].sample is a garbage

I do not have test application, but in my code it's something like

S_StopMusic();
I_ShutdownMusic();

S_Stop();
I_ShutdownSound();

use_experimental_music = experimental_music;

I_InitSound();
S_RestartMusic();

SVN:
https://www.crowproductions.de/repos/prboom/branches/prboom-plus-24/prboom2

-------------------------------
Crash report by Dr.Watson:

*** WARNING: Unable to verify checksum for D:\games\Doom2\SDL_mixer.dll
функция: SDL_mixer!recompute_amp
        00ae6dcf 00e9             add     cl,ch
        00ae6dd1 60               pushad
        00ae6dd2 0300             add     eax,[eax]
        00ae6dd4 00db             add     bl,bl
        00ae6dd6 45               inc     ebp
        00ae6dd7 d48b             aam     ???
        00ae6dd9 4d               dec     ebp
        00ae6dda 0869c9           or      [ecx-0x37],ch
        00ae6ddd c8010000         enter   0x1,0x0
        00ae6de1 8b91c82ab100     mov     edx,[ecx+0xb12ac8]
CRASH-> 00ae6de7 dc8a90000000 fmul qword ptr [edx+0x90] ds:0023:032e83d8=????????????????
        00ae6ded dc0d4000b300 fmul qword ptr [SDL_mixer!GS_ContextRecord+0x25228 (00b30040)]
        00ae6df3 dd5dc0           fstp    qword ptr [ebp-0x40]
        00ae6df6 c745cc40000000   mov     dword ptr [ebp-0x34],0x40
        00ae6dfd 833dd4b7b00004 cmp dword ptr [SDL_mixer!GS_ContextRecord+0x9bc (00b0b7d4)],0x4
        00ae6e04 7507             jnz     SDL_mixer!recompute_amp+0x31d (00ae6e0d)
        00ae6e06 c745cc5f000000   mov     dword ptr [ebp-0x34],0x5f
        00ae6e0d 8b4508           mov     eax,[ebp+0x8]
        00ae6e10 69c0c8010000     imul    eax,eax,0x1c8
        00ae6e16 c780842cb10000000000 mov dword ptr [eax+0xb12c84],0x0
        00ae6e20 dd45c0           fld     qword ptr [ebp-0x40]

*----> Обратная трассировка стека <----*
*** WARNING: Unable to verify checksum for D:\games\Doom2\glboom-plus.exe
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\system32\kernel32.dll - 
WARNING: Stack unwind information not available. Following frames may be wrong.
ChildEBP RetAddr  Args to Child              
0012f570 00ae92b2 0000000b 0000000b 0012f5dc SDL_mixer!recompute_amp+0x2f7
0012f580 00ae0f62 00000080 0000005a 00000000 SDL_mixer!Timidity_SetVolume+0x72
0012f5dc 00ae0ebb 00000080 0000005a 00000000 SDL_mixer!music_internal_volume+0x82
0012f634 00ae09c3 0000005a 00000000 7ffd4000 SDL_mixer!music_internal_initialize_volume+0x2b
0012f690 00ae0c3d 032df8b0 00000000 00000000 SDL_mixer!music_internal_play+0x33
0012f6f4 00ae0cf0 032df8b0 ffffffff 00000000 SDL_mixer!Mix_FadeInMusicPos+0xad
0012f75c 00547a19 032df8b0 ffffffff 0000005a SDL_mixer!Mix_PlayMusic+0x20
0012f7b8 00603ac0 00000000 00000001 0000005a glboom-plus!I_PlaySong+0x49
0012f830 00603b78 00000042 00000001 0000005a glboom-plus!S_ChangeMusic+0x150
0012f88c 00548c49 0000005a 00000000 7ffd4000 glboom-plus!S_RestartMusic+0x28
0012f8e4 00555494 0000005a 00000000 7ffd4000 glboom-plus!M_ChangeMIDIPlayer+0x159
0012f9a8 00526f25 0012fa74 0000005a 00000000 glboom-plus!M_Responder+0x1194
0012fa00 00549fc3 0012fa74 0000005a 00000000 glboom-plus!D_PostEvent+0x55
0012fa84 00549efe 0000005a 00000000 7ffd4000 glboom-plus!I_GetEvent+0xa3
0012fad8 00521386 0000005a 00000000 7ffd4000 glboom-plus!I_StartTic+0xe
0012fb64 005217ee 0000005a 00000000 7ffd4000 glboom-plus!NetUpdate+0x2b6
0012fbd4 0052821b 0000005a 00000000 7ffd4000 glboom-plus!TryRunTics+0x2e
0012fc28 00528163 0000005a 00000000 7ffd4000 glboom-plus!D_DoomLoop+0xab
0012fc7c 005457bc 0000005a 00000000 7ffd4000 glboom-plus!D_DoomMain+0x13
0012fcd0 00645903 00000002 0012fd60 6f626c67 glboom-plus!SDL_main+0xec
0012fd50 00645dc6 00000002 0012fd60 0012fd71 glboom-plus!main+0x133
0012ff14 006bafa6 00400000 00000000 00152331 glboom-plus!WinMain+0x286
0012ffb8 006bae2f 0012fff0 7c817077 0000005a glboom-plus!__tmainCRTStartup+0x166
0012ffc0 7c817077 0000005a 00000000 7ffd4000 glboom-plus!WinMainCRTStartup+0xf
0012fff0 00000000 005173ae 00000000 78746341 kernel32!RegisterWaitForInputIdle+0x49
Comment 1 Andrey Budko 2011-05-23 04:59:37 UTC
You can download my project from
https://www.crowproductions.de/repos/prboom/branches/prboom-plus-24/prboom2

Re-enable code after "#if 0" at end of i_sound.c in M_ChangeMIDIPlayer()

Activate timidity and try to switch between "sdl" and "opl2" music players few times ("Menu\Options\General\Preferred MIDI player" GUI option).

I was not able to reproduce the crash if timidity is not active.
Comment 2 Andrey Budko 2011-05-23 05:06:17 UTC
Created attachment 612 [details]
dr. watson log
Comment 3 Ryan C. Gordon 2011-12-31 11:39:17 UTC
Bumping priority on a few SDL_mixer bugs. This is just so we know to look at them for an upcoming release, but once we look at them more closely, we may decide to flag them as WONTFIX or push them back to a later release, so don't take this change in priority as any promise of anything, yet.  :)

--ryan.
Comment 4 Sam Lantinga 2012-01-01 14:10:47 UTC
I tried to reproduce this in playmus by shutting down and reinitializing music playback with no success.

I also tried to grab prboom-plus-24 and reproduce it on my Mac, but I ran into a bug with deutex trying to import textures for doom.wad.  It also occurred to me that probably wouldn't work because it looks like there aren't other MIDI output options there.

Do you have a build with data that I can test on?