Crashing when using Mix_SetMusicPosition

Hello,

Doing some other things (actually in Python and Pygame) I had some
strange problem that I could reproduce, I think.

Problem: when I’m using the function Mix_SetMusicPosition(aleatori) the
program is crashing every now and then. See the attached brief code
code. Usually it crash before 300 iterations, but it depends. I’m always
using the same seed to generate the random numbers and it’s crashing in
different points, so it’s not particular case.

If I change:
Mix_SetMusicPosition(aleatori);
by:
Mix_SetMusicPosition(0.0);

Then it’s not crashing anymore.

I’ve tested it in two computers with the same results (always Debian
GNU/Linux)

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/libsmpeg-0.4.so.0
#6 0xb7eebf7b in ?? () from /usr/lib/libSDL-1.2.so.0
#7 0x08085048 in ?? ()
#8 0xb7abccb0 in ?? () from /usr/lib/libsmpeg-0.4.so.0
#9 0x08084808 in ?? ()
#10 0xb7f44840 in ?? () from /usr/lib/libSDL-1.2.so.0
#11 0x00000000 in ?? ()
(gdb)

I’m using a Debian Testing/Unstable, with this quite recent versions:
ii libsdl-mixer1.2 1.2.8-4 mixer library for Simple DirectMedia Layer 1
ii libsdl-mixer1.2-dev 1.2.8-4 development files for SDL1.2 mixer library

I haven’t tested using SVN version :frowning:

Do you want that I report this somewhere else? (like some mail, bug
tracking system, etc.)

Thanks,–
Carles Pina i Estany GPG id: 0x17756391
http://pinux.info
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl-mixer-crash.c
Type: text/x-csrc
Size: 1385 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20081207/9afb96c9/attachment.c

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/
libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/
libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/
libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/libsmpeg-0.4.so.0

Seems to me like a problem in libsmpeg-0.4, not in SDL.

I would contact the libsmpeg team.Am 07.12.2008 um 16:32 schrieb Carles Pina i Estany:

Hello,On Dec/07/2008, Albert Zeyer wrote:

Am 07.12.2008 um 16:32 schrieb Carles Pina i Estany:

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/
libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/
libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/
libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/libsmpeg-0.4.so.0

Seems to me like a problem in libsmpeg-0.4, not in SDL.

I would contact the libsmpeg team.

You are right (before I thought that smpeg was part of SDL, I see that
it’s a completely different project). I’m preparing the test case in
SMPEG and I ask there.

Thanks,


Carles Pina i Estany GPG id: 0x17756391
http://pinux.info

Hi,On Dec/07/2008, Carles Pina i Estany wrote:

Hello,

On Dec/07/2008, Albert Zeyer wrote:

Am 07.12.2008 um 16:32 schrieb Carles Pina i Estany:

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/
libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/
libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/
libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/libsmpeg-0.4.so.0

Seems to me like a problem in libsmpeg-0.4, not in SDL.

I would contact the libsmpeg team.

You are right (before I thought that smpeg was part of SDL, I see that
it’s a completely different project). I’m preparing the test case in
SMPEG and I ask there.

I’ve done the same example but only using libsmpeg and not SDL-mixer.
See the attached file.

The interesting part is that smpeg is not crashing. I know that, from
the backtrace, it’s libsmpeg-0.4 blame. But I wonder if SDL-mixer is not
freeing some smpeg pointer or something like this, and this is the
reason that smpeg is crashing.

Or SDL-mixer is using the smpeg in a different way that I do and this
"other way" is making it to crash.

I would complain myself to smpeg people if I can reproduce the crash
using only smpeg (are they still working on smpeg project? last commit
in the SVN is from 2007-06-14!!. I prefer to ask some more things here
because I cannot reproduce the crash :frowning:

Thanks for your help,


Carles Pina i Estany GPG id: 0x17756391
http://pinux.info
-------------- next part --------------
A non-text attachment was scrubbed…
Name: smpeg.c
Type: text/x-csrc
Size: 923 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20081207/757f919f/attachment.c

Hi,

Hello,

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/
libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/
libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/
libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/
libsmpeg-0.4.so.0

Seems to me like a problem in libsmpeg-0.4, not in SDL.

I would contact the libsmpeg team.

You are right (before I thought that smpeg was part of SDL, I see
that
it’s a completely different project). I’m preparing the test case in
SMPEG and I ask there.

I’ve done the same example but only using libsmpeg and not SDL-mixer.
See the attached file.

The interesting part is that smpeg is not crashing. I know that, from
the backtrace, it’s libsmpeg-0.4 blame. But I wonder if SDL-mixer is
not
freeing some smpeg pointer or something like this, and this is the
reason that smpeg is crashing.

Or SDL-mixer is using the smpeg in a different way that I do and this
"other way" is making it to crash.

I would complain myself to smpeg people if I can reproduce the crash
using only smpeg (are they still working on smpeg project? last
commit
in the SVN is from 2007-06-14!!. I prefer to ask some more things here
because I cannot reproduce the crash :frowning:

Thanks for your help,

You are using smpeg in your example for playing. SDL_mixer just uses
smpeg for decoding and plays via SDL.

Perhaps just look at the SDL_mixer source how it is done there. It
could be that SDL_mixer has allocated too less memory (then it is a
bug of SDL_mixer) or smpeg is copying too much data in the provided
buffer from SDL (then it is a bug from smpeg).

I would try to create an example in where you use smpeg only for
decoding (like SDL_mixer, use the Decode_MPEGaudio() function),
similar to SDL_mixer. You don’t really need to play the decoded data,
the bug should occur already at the decoding.

  • AlbertAm 07.12.2008 um 17:39 schrieb Carles Pina i Estany:

On Dec/07/2008, Carles Pina i Estany wrote:

On Dec/07/2008, Albert Zeyer wrote:

Am 07.12.2008 um 16:32 schrieb Carles Pina i Estany:

Hello,

Hi,

Hello,

The backtrace looks like:
Program terminated with signal 11, Segmentation fault.
[New process 28318]
[New process 27029]
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7da0cac in memcpy () from /lib/i686/cmov/libc.so.6
#1 0xb7aa6eee in MPEGstream::copy_data () from /usr/lib/
libsmpeg-0.4.so.0
#2 0xb7aabbae in MPEGaudio::fillbuffer () from /usr/lib/
libsmpeg-0.4.so.0
#3 0xb7abc8bb in MPEGaudio::loadheader () from /usr/lib/
libsmpeg-0.4.so.0
#4 0xb7abcb24 in MPEGaudio::run () from /usr/lib/libsmpeg-0.4.so.0
#5 0xb7abcd38 in Decode_MPEGaudio () from /usr/lib/
libsmpeg-0.4.so.0

Seems to me like a problem in libsmpeg-0.4, not in SDL.

I would contact the libsmpeg team.

You are right (before I thought that smpeg was part of SDL, I see
that
it’s a completely different project). I’m preparing the test case in
SMPEG and I ask there.

I’ve done the same example but only using libsmpeg and not SDL-mixer.
See the attached file.

The interesting part is that smpeg is not crashing. I know that, from
the backtrace, it’s libsmpeg-0.4 blame. But I wonder if SDL-mixer is
not
freeing some smpeg pointer or something like this, and this is the
reason that smpeg is crashing.

Or SDL-mixer is using the smpeg in a different way that I do and this
"other way" is making it to crash.

I would complain myself to smpeg people if I can reproduce the crash
using only smpeg (are they still working on smpeg project? last
commit
in the SVN is from 2007-06-14!!. I prefer to ask some more things here
because I cannot reproduce the crash :frowning:

Thanks for your help,

You are using smpeg in your example for playing. SDL_mixer just uses
smpeg for decoding and plays via SDL.

Perhaps just look at the SDL_mixer source how it is done there. It could
be that SDL_mixer has allocated too less memory (then it is a bug of
SDL_mixer) or smpeg is copying too much data in the provided buffer from
SDL (then it is a bug from smpeg).

I would try to create an example in where you use smpeg only for
decoding (like SDL_mixer, use the Decode_MPEGaudio() function), similar

I don’t think that SDL_mixer is using this function:
carles at pinux:~/tmp$ ls
SDL-1.2.13 SDL_mixer-1.2.8
carles at pinux:~/tmp$ rgrep Decode_MPEGaudio *
carles at pinux:~/tmp$On Dec/07/2008, Albert Zeyer wrote:

Am 07.12.2008 um 17:39 schrieb Carles Pina i Estany:

On Dec/07/2008, Carles Pina i Estany wrote:

On Dec/07/2008, Albert Zeyer wrote:

Am 07.12.2008 um 16:32 schrieb Carles Pina i Estany:

to SDL_mixer. You don’t really need to play the decoded data, the bug
should occur already at the decoding.

From my code:


    Mix_Music *music;
    music=Mix_LoadMUS("Qt4Dance.mp3");
    fprintf(stderr,"After Mix_LoadMus\n");
    Mix_PlayMusic(music,0);
    fprintf(stderr,"After Mix_PlayMusic\n");
    Mix_RewindMusic();
    fprintf(stderr,"After Mix_RewindMusic\n");
    Mix_SetMusicPosition(aleatori);
    fprintf(stderr,"After Mix_SetMusicPosition\n");
    //sleep(1);

    Mix_HaltChannel(-1);
    fprintf(stderr,"After HaltChannel\n");
    Mix_FreeMusic(music);
    fprintf(stderr,"After Mix_HaltChannel\n");

and the output:

Iteration: 270
After Mix_LoadMus
After Mix_PlayMusic
After Mix_RewindMusic
Audio: Skipping 25.503183 seconds…
Violaci? de segment
carles at pinux:~/pygame$

I see that it crashes in Mix_SetMusicPosition.

Mix_SetMusicPosition executes (SDL_mixer-1.2.8/music.c):

    if ( music_playing ) {
            retval = music_internal_position(position);
            if ( retval < 0 ) {
                    Mix_SetError("Position not implemented for music type");
            }

so music_internal_position does, in MP3 case:

            if ( position > 0.0 ) {
                    smpeg.SMPEG_skip(music_playing->data.mp3, (float)position);
            } else {
                    smpeg.SMPEG_rewind(music_playing->data.mp3);
                    smpeg.SMPEG_play(music_playing->data.mp3);
            }

So it seems that SDL_mixer is doing something very similar of what I was doing (but it’s crashing), but I cannot see that SDL uses Decode_MPEGaudio, and it seems that it’s using smpeg to play the file itself.

Also, it’s creating the basic structures like me (line 620 in music.c)

I don’t have the development things (sourcecode from the libraries to be
changed, etc.) and will take some time if I have to do it.


Carles Pina i Estany GPG id: 0x17756391
http://pinux.info

Am I the only one that thinks the random numbers he’s giving ought to
be investigated a little more before trying anything else?

If there’s a pattern to the values that cause crashes, that might give
you the information you’re looking for.–
http://codebad.com/

Hello,On Dec/08/2008, Donny Viszneki wrote:

Am I the only one that thinks the random numbers he’s giving ought to
be investigated a little more before trying anything else?

If there’s a pattern to the values that cause crashes, that might give
you the information you’re looking for.

I executed more than 10 or 15 times, and it’s always crashing in different
places. I’m using the same random seed, so I always have the same
"random" numbers.

Right now I don’t have time to look on it more :frowning: and I don’t have any
experience with SDL-smpeg-… programming so I think that would take a
bit long for me :slight_smile:
(When I will have time I will look further, of course)


Carles Pina i Estany GPG id: 0x17756391
http://pinux.info