SDL_mixer segmentation fault

I’m using SDL_mixer for the first time, and it appears there may be a
bug in it. In a program I am writing, it randomly crashes during the
following:

if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) {
cerr << "Error: could not initialize SDL: " << SDL_GetError() << endl;
return 1;
}
atexit(SDL_Quit);

cout << “about to open audio” << endl;
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 1024) == -1) {
cout << "Couldn’t open audio: " << SDL_GetError() << endl;
return 1;
}
cout << “audio open” << endl;

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call. It doesn’t even
return with an error so that the cout << “Couldn’t open audio” stuff
can be printed. When it fails, my output looks like:

about to open audio
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

I also downloaded, compiled, and ran sdlwav.c and it is doing the same
thing.

I’m running fedora, kde, and arts. SDL_mixer is 1.2.5. I would say on
average it seg faults 1 out of 4 times I run the program.

Anyone have any advice or ideas I can try? Is there anything I can do
to help narrow it down better?–
Jason Stechschulte
@Jason_Stechschulte

Either I’m dead or my watch has stopped.
– Groucho Marx’s last words

I’m using SDL_mixer for the first time, and it appears there may be a
bug in it. In a program I am writing, it randomly crashes during the
following:

if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) {
cerr << "Error: could not initialize SDL: " << SDL_GetError() << endl;
return 1;
}
atexit(SDL_Quit);

cout << “about to open audio” << endl;
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 1024) == -1) {
cout << "Couldn’t open audio: " << SDL_GetError() << endl;
return 1;
}
cout << “audio open” << endl;

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call.

Can you run it under the debugger and get a stack trace?

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Jason Stechschulte wrote:

I’m using SDL_mixer for the first time, and it appears there may be a
bug in it. In a program I am writing, it randomly crashes during the
following:

if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) {
cerr << "Error: could not initialize SDL: " << SDL_GetError() << endl;
return 1;
}
atexit(SDL_Quit);

cout << “about to open audio” << endl;
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 1, 1024) == -1) {
cout << "Couldn’t open audio: " << SDL_GetError() << endl;
return 1;
}
cout << “audio open” << endl;

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call. It doesn’t even
return with an error so that the cout << “Couldn’t open audio” stuff
can be printed. When it fails, my output looks like:

about to open audio
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

I also downloaded, compiled, and ran sdlwav.c and it is doing the same
thing.

I’m running fedora, kde, and arts. SDL_mixer is 1.2.5. I would say on
average it seg faults 1 out of 4 times I run the program.

It this FC1 or FC2 ? I still have FC2 on a spare hard drive, I was going
to wipe it, but if it is FC2 I could give it a look.

Stephane

After a bit of reading up on it I should be able to do it. When I
figure it out, I will send the stack trace.On Wed, Jun 09, 2004 at 09:47:21AM -0700, Sam Lantinga wrote:

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call.

Can you run it under the debugger and get a stack trace?


Jason Stechschulte
@Jason_Stechschulte

No people are all bad, just as none are all good.
Tecumseh, (Shawnee) to his nephew Spemica Lawba 1790

Its FC1.On Wed, Jun 09, 2004 at 07:51:16PM +0200, Stephane Marchesin wrote:

It this FC1 or FC2 ? I still have FC2 on a spare hard drive, I was going
to wipe it, but if it is FC2 I could give it a look.


Jason Stechschulte
@Jason_Stechschulte

Each man is his own prisoner, in solitary confinement for life.

Here is the result of strace. I didn’t send the entire thing since it
is rather long. If you need more, I can send it though.

fstat64(1, {st_mode=S_IFREG|0664, st_size=0, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xbf556000
write(1, “about to open audio\n”, 20) = 20
open("/usr/lib/libartscbackend.la", O_RDONLY) = 5
fstat64(5, {st_mode=S_IFREG|0755, st_size=1045, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xbf555000
read(5, “# libartscbackend.la - a libtool”…, 4096) = 1045
read(5, “”, 4096) = 0
close(5) = 0
munmap(0xbf555000, 4096) = 0
open("/usr/lib/libartscbackend.so.0", O_RDONLY) = 5
read(5, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000\211”…,
512) = 512
fstat64(5, {st_mode=S_IFREG|0755, st_size=69720, …}) = 0
old_mmap(NULL, 72696, PROT_READ|PROT_EXEC, MAP_PRIVATE, 5, 0) = 0x672000
old_mmap(0x681000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
5, 0xe000) = 0x681000
close(5) = 0
open("/usr/lib/tls/libsoundserver_idl.so.1", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/libsoundserver_idl.so.1", O_RDONLY) = 5
read(5, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\344”…,
512) = 512
fstat64(5, {st_mode=S_IFREG|0755, st_size=455500, …}) = 0
old_mmap(0x36e8000, 456760, PROT_READ|PROT_EXEC, MAP_PRIVATE, 5, 0) =
0x1fe000
old_mmap(0x258000, 90112, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
5, 0x59000) = 0x258000
close(5) = 0
open("/usr/lib/tls/libkmedia2_idl.so.1", O_RDONLY) = -1 ENOENT (No such
file or directory)
open("/usr/lib/libkmedia2_idl.so.1", O_RDONLY) = 5
read(5, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240\305”…,
512) = 512
fstat64(5, {st_mode=S_IFREG|0755, st_size=306232, …}) = 0
old_mmap(0xa28000, 303440, PROT_READ|PROT_EXEC, MAP_PRIVATE, 5, 0) =
0x26e000
old_mmap(0x2aa000, 61440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
5, 0x3c000) = 0x2aa000
close(5) = 0
time(NULL) = 1086806964
getpid() = 6612
uname({sys=“Linux”, node=“host-65-17-129-179.wcoil.com”, …}) = 0
pipe([5, 6]) = 0
gettimeofday({1086806964, 207764}, NULL) = 0
rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
gettimeofday({1086806964, 313554}, NULL) = 0
— SIGSEGV (Segmentation fault) @ 0 (0) —
+++ killed by SIGSEGV +++On Wed, Jun 09, 2004 at 09:47:21AM -0700, Sam Lantinga wrote:

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call.

Can you run it under the debugger and get a stack trace?


Jason Stechschulte
@Jason_Stechschulte

FORTUNE’S RULES TO LIVE BY: #23
Don’t cut off a police car when making an illegal U-turn.

Jason Stechschulte wrote:>On Wed, Jun 09, 2004 at 09:47:21AM -0700, Sam Lantinga wrote:

It sometimes gets past this code fine and plays the background music.
Other times it seg faults on the Mix_OpenAudio call.

Can you run it under the debugger and get a stack trace?

Here is the result of strace. I didn’t send the entire thing since it
is rather long. If you need more, I can send it though.

[snip a system trace]

Hmm, that’s not a stack trace but a system trace. Different things, but
same goal usually :slight_smile:
To get a stack trace :

  • compile your code with -g (or --enable-debug)
  • run your code under gdb : “gdb ./mycode”
  • start the program : “run”
  • make it crash
  • type “bt”, that gives you a backtrace, a.k.a stack trace
  • type “where” also, that can be useful

Stephane

Ok, sorry about that. Here is the stack trace:

(gdb) run
Starting program: /home/video/slideshow/slideshow
[Thread debugging using libthread_db enabled]
[New Thread -1084885152 (LWP 7006)]
about to open audio

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1084885152 (LWP 7006)]
0x00bcffec in Arts::StartupManager::startup() () from
/usr/lib/libmcop.so.1
(gdb) bt
#0 0x00bcffec in Arts::StartupManager::startup() () from
/usr/lib/libmcop.so.1
#1 0x00bb6377 in Arts::Dispatcher::Dispatcher(Arts::IOManager*,
Arts::Dispatcher::StartServer) ()
from /usr/lib/libmcop.so.1
#2 0x00206b15 in arts_backend_init () from
/usr/lib/libartscbackend.so.0
#3 0x00862776 in arts_init () from /usr/lib/libartsc.so.0
#4 0x055981d9 in SDL_FreeWAV () from /usr/lib/libSDL-1.2.so.0
#5 0x05593e9e in SDL_OpenAudio () from /usr/lib/libSDL-1.2.so.0
#6 0x00960c8a in Mix_OpenAudio () from /usr/lib/libSDL_mixer-1.2.so.0
#7 0x0804b980 in main (argc=1, argv=0xbfed4bd4) at slideshow.cpp:46
(gdb) where
#0 0x00bcffec in Arts::StartupManager::startup() () from
/usr/lib/libmcop.so.1
#1 0x00bb6377 in Arts::Dispatcher::Dispatcher(Arts::IOManager*,
Arts::Dispatcher::StartServer) ()
from /usr/lib/libmcop.so.1
#2 0x00206b15 in arts_backend_init () from
/usr/lib/libartscbackend.so.0
#3 0x00862776 in arts_init () from /usr/lib/libartsc.so.0
#4 0x055981d9 in SDL_FreeWAV () from /usr/lib/libSDL-1.2.so.0
#5 0x05593e9e in SDL_OpenAudio () from /usr/lib/libSDL-1.2.so.0
#6 0x00960c8a in Mix_OpenAudio () from /usr/lib/libSDL_mixer-1.2.so.0
#7 0x0804b980 in main (argc=1, argv=0xbfed4bd4) at slideshow.cpp:46On Wed, Jun 09, 2004 at 08:57:14PM +0200, Stephane Marchesin wrote:

Hmm, that’s not a stack trace but a system trace. Different things, but
same goal usually :slight_smile:
To get a stack trace :
[snip steps]


Jason Stechschulte
@Jason_Stechschulte

The farther you go, the less you know.
– Lao Tsu, “Tao Te Ching”

(gdb) bt
#0 0x00bcffec in Arts::StartupManager::startup() () from
/usr/lib/libmcop.so.1
#1 0x00bb6377 in Arts::Dispatcher::Dispatcher(Arts::IOManager*,
Arts::Dispatcher::StartServer) ()
from /usr/lib/libmcop.so.1
#2 0x00206b15 in arts_backend_init () from
/usr/lib/libartscbackend.so.0
#3 0x00862776 in arts_init () from /usr/lib/libartsc.so.0

Hum. There’s not much we can do about crashes in the arts sound server.
You can specify the audio driver directly, by setting the SDL_AUDIODRIVER
environment variable to: dsp

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Nope, I don’t suppose there is. I just thought it was odd that my
program and sdlwav.c both crashed, but other programs ran fine. The
stack trace clearly shows where it is crashing though.

Do these other programs somehow handle that error and proceed to try a
different audio driver? Is it possible to catch another library’s
segfault and continue nicely?

Anyway, I started setting SDL_AUDIODRIVER to esd and that seems to work
fine.On Thu, Jun 10, 2004 at 11:31:25PM -0700, Sam Lantinga wrote:

Hum. There’s not much we can do about crashes in the arts sound server.
You can specify the audio driver directly, by setting the SDL_AUDIODRIVER
environment variable to: dsp


Jason Stechschulte
@Jason_Stechschulte

Beauty is one of the rare things which does not lead to doubt of God.
– Jean Anouilh