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

Segmentation fault on playing sounds #37

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Segmentation fault on playing sounds #37

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.8
Reported for operating system, platform: Windows (XP), x86

Comments on the original bug report:

On 2008-01-09 03:46:47 +0000, Carl Castanier wrote:

We use sdl_mixer for http://svn.gna.org/viewcvs/freeciv-warclient/trunk/client/audio_sdl.c?rev=799&view=log
We don't use other function of SDL so I submit bug here.

I compile under Windows with SDL 1.2.13 (latest). During games, I have sometimes a crash. It's appends when many sounds must be played at same times. In our case many units attacks and each play sounds. I have recorded backtrave with gdb if it can help you.

(gdb) bt

0 0x62760fbd in _libuser32_a_iname ()

1 0x6276e5f4 in _libuser32_a_iname ()

2 0x6b06c388 in _libuser32_a_iname ()

3 0x6b06c3b0 in _libuser32_a_iname ()

4 0x6b06f7fb in _libuser32_a_iname ()

5 0x6b070e74 in _libuser32_a_iname ()

6 0x7e398734 in _libmsvcrt_a_iname ()

7 0x7e398816 in _libmsvcrt_a_iname ()

8 0x7e39b4c0 in _libmsvcrt_a_iname ()

9 0x7e39b50c in _libmsvcrt_a_iname ()

10 0x7c91eae3 in _libmsvcrt_a_iname ()

11 0x6b06c3b0 in _libuser32_a_iname ()

12 0x6b06f7fb in _libuser32_a_iname ()

13 0x6b070e74 in _libuser32_a_iname ()

14 0x7e398734 in _libmsvcrt_a_iname ()

15 0x7e398816 in _libmsvcrt_a_iname ()

16 0x7e39b4c0 in _libmsvcrt_a_iname ()

17 0x7e39b50c in _libmsvcrt_a_iname ()

18 0x7c91eae3 in _libmsvcrt_a_iname ()

19 0x7e39b3f9 in _libmsvcrt_a_iname ()

20 0x5b093c20 in end_ ()

21 0x5b0ae300 in end_ ()

22 0x5b091ac7 in end_ ()

23 0x5b091b3d in end_ ()

24 0x7e39bb15 in _libmsvcrt_a_iname ()

25 0x6b06db10 in _libuser32_a_iname ()

26 0x6b070e74 in _libuser32_a_iname ()

27 0x7e398734 in _libmsvcrt_a_iname ()

28 0x7e398816 in _libmsvcrt_a_iname ()

29 0x7e39b89b in _libmsvcrt_a_iname ()

30 0x7e39b903 in _libmsvcrt_a_iname ()

31 0x5b0b881f in end_ ()

32 0x5b091ac7 in end_ ()

33 0x5b091b3d in end_ ()

34 0x7e39bb15 in _libmsvcrt_a_iname ()

35 0x6b06db10 in _libuser32_a_iname ()

36 0x6b070e74 in _libuser32_a_iname ()

37 0x7e398734 in _libmsvcrt_a_iname ()

38 0x7e398816 in _libmsvcrt_a_iname ()

39 0x7e3989cd in _libmsvcrt_a_iname ()

40 0x7e398a10 in _libmsvcrt_a_iname ()

41 0x6b070f6d in _libuser32_a_iname ()

42 0x6b0710ed in _libuser32_a_iname ()

43 0x672de877 in _libmsvcrt_a_iname ()

44 0x672dfd5b in _libmsvcrt_a_iname ()

45 0x672dff3a in _libmsvcrt_a_iname ()

46 0x60589c2e in end_ ()

47 0x004c227f in ui_main ()

48 0x004055ec in SDL_main ()

49 0x00505eeb in console_main (argc=1, argv=0x3d4c90)

at ./src/main/win32/SDL_win32_main.c:246

50 0x005060c9 in WinMain (hInst=0x400000, hPrev=0x0, szCmdLine=0x241f12 "",

sw=10) at ./src/main/win32/SDL_win32_main.c:382

Cordially

On 2008-06-30 20:50:39 +0000, Roger Booth wrote:

This bug report may be a duplicate of 539 - Segmentation fault on playing sounds.

However, I can give a specific procedure to quickly and easily replicate the crash.

I created a standard Single-Document-Interface Windows SDK application. In WinMain, before creating the main window, I initialized SDL and after the main loop exited, I shut down SDL. One menu option invoked a dialog. On this dialog were three buttons, although two would be sufficient.

Two of the the three buttons on the dialog were set up to play wave files using Mix_LoadWAV() and Mix_PlayChannel().

The third was set up to play a .MP3 file using Mix_LoadMUS() and Mix_PlayMusic(). I used a Windows timer to poll for the end of the .MP3 file, calling Mix_PlayingMusic() on each timer message. The button to play the .MP3 was disabled while the .MP3 file was being played.

I found that I could start up many of the wave files in rapid succession, such that I could hear them overlapping each other - that part worked fine.

I found that I could play the .MP3 file in succession many times without problems. The fact that the button to play the .MP3 was disabled until the file was finished playing kept me from mixing two .MP3 files together, which I assume is beyond the capabilities of SDL_mixer. No complaints there.

I am able to trigger the bug very regularly (not every time, but most times) by playing a wave file, and while the wave file is still playing, start to play the .MP3 file.

When I trigger the error, the error is in the file mpegstream.cpp in the function MPEGstream::copy_byte(), in the final statement - return(*data++);

The error is an attempt to dereference a null pointer. The Microsoft Development Environment reports the following:

Unhandled exception at 0x01741242 (smpeg.dll) in TestApplication.exe: 0xC0000005: Access violation reading location 0x00000000.

SDL 1.2.13
SDL_mixer 1.2.8
SMPEG 0.4.5
MSWindows 2000 Professional Service Pack 4
Microsoft Development Environment 2003 7.1.3088

On 2009-10-03 02:56:45 +0000, Sam Lantinga wrote:

We've fixed a bunch of crash bugs lately, can you check out this snapshot?
http://www.libsdl.org/tmp/SDL_mixer.zip

Thanks!

On 2009-10-10 02:16:32 +0000, Ryan C. Gordon wrote:

I'm inclined to think this is an SMPEG bug and not an SDL_mixer bug.

This is what Valgrind finds in playmus for a random MP3 that is otherwise playing fine with SDL_mixer...

(SMPEG predates Valgrind, and hasn't received much attention since.)

Opened audio at 22050 Hz 16 bit stereo (LE), 4096 bytes audio buffer
==31631== Conditional jump or move depends on uninitialised value(s)
==31631== at 0x6FCE96C: MPEGaudio::Stop() (MPEGaudio.cpp:205)
==31631== by 0x6FCEA89: MPEGaudio::Rewind() (MPEGaudio.cpp:219)
==31631== by 0x6FE0C66: MPEGaudio::initialize() (mpegtoraw.cpp:128)
==31631== by 0x6FCEE28: MPEGaudio::MPEGaudio(MPEGstream*, bool) (MPEGaudio.cpp:33)
==31631== by 0x6FC857D: MPEG::parse_stream_list() (MPEG.cpp:492)
==31631== by 0x6FC8EEA: MPEG::Init(SDL_RWops*, bool) (MPEG.cpp:106)
==31631== by 0x6FCE422: SMPEG_new (smpeg.cpp:84)
==31631== by 0x4E39534: Mix_LoadMUS (music.c:521)
==31631== by 0x401884: main (playmus.c:196)
Playing /home/icculus/rodeo.mp3
==31631==
==31631== Thread 3:
==31631== Conditional jump or move depends on uninitialised value(s)
==31631== at 0x6FDDBF6: MPEGaudio::layer3hybrid(int, int, float () [18], float () [32]) (mpeglayer3.cpp:1631)
==31631== by 0x6FDF547: MPEGaudio::extractlayer3() (mpeglayer3.cpp:1762)
==31631== by 0x6FE0934: MPEGaudio::run(int, double*) (mpegtoraw.cpp:314)
==31631== by 0x6FE0A2F: Decode_MPEGaudio(void*) (mpegtoraw.cpp:372)
==31631== by 0x5088816: SDL_RunThread (SDL_thread.c:204)
==31631== by 0x50D07D8: RunThread (SDL_systhread.c:47)
==31631== by 0x5E373B9: start_thread (in /lib/libpthread-2.9.so)
==31631== by 0x6131FCC: clone (in /lib/libc-2.9.so)
==31631==
==31631== Conditional jump or move depends on uninitialised value(s)
==31631== at 0x6FDDBF6: MPEGaudio::layer3hybrid(int, int, float () [18], float () [32]) (mpeglayer3.cpp:1631)
==31631== by 0x6FDF746: MPEGaudio::extractlayer3() (mpeglayer3.cpp:1766)
==31631== by 0x6FE0934: MPEGaudio::run(int, double*) (mpegtoraw.cpp:314)
==31631== by 0x6FE0A2F: Decode_MPEGaudio(void*) (mpegtoraw.cpp:372)
==31631== by 0x5088816: SDL_RunThread (SDL_thread.c:204)
==31631== by 0x50D07D8: RunThread (SDL_systhread.c:47)
==31631== by 0x5E373B9: start_thread (in /lib/libpthread-2.9.so)
==31631== by 0x6131FCC: clone (in /lib/libc-2.9.so)

--ryan.

On 2009-10-10 19:27:28 +0000, Ryan C. Gordon wrote:

svn revision # 386 in smpeg's repository fixes the valgrind issues mentioned here, but I can't say if they cause this bug (however, one of them is an uninitialized variable being checked when starting playback of a new MP3). This is as far as I can go with this bug.

--ryan.

On 2009-10-10 21:08:01 +0000, Sam Lantinga wrote:

Can you retest with the latest code from subversion?

Thanks!

On 2010-04-16 20:26:24 +0000, wrote:

(And by quick and dirty fix, bad organization of needed headers in the project).

On 2010-04-16 20:28:41 +0000, wrote:

(Sorry about the above comment - browser decided to (unknowingly) move me to this bug while commenting on a different bug)

On 2011-12-31 10:48:00 +0000, Sam Lantinga wrote:

Waiting for several years on this one. :)

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

1 participant