8-line SDL program seg faults!

The following program seg faults after SQL_Quit(). Anyone have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

-John

Millaway, John wrote:

The following program seg faults after SQL_Quit(). Anyone have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

-John


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Try this instead:

#include "SDL.h"
int main ( int argc, char *argv[] ){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

The following program seg faults after SQL_Quit(). Anyone
have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

Try this instead:

#include "SDL.h"
int main ( int argc, char *argv[] ){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

That won’t help. The seg fault is somewhere deep in the guts of an `atexit’
routine installed somewhere by SDL audio.

I don’t see why you are having a segfault. Other than the fact that exit is
defined in <stdlib.h> (adding a -Wall to the end of your compile statement
will give you all warnings).

This ran on Linux, a particularly stubborn box I might add, without issue:
jclark gerbilater ~/testc) gcc sdl-config --cflags testsdl.c
sdl-config --static-libs -Wall
jclark gerbilater ~/testc) ./a.out
Returning…
jclark gerbilater ~/testc)

jclark gerbilater ~/testc) cat testsdl.c
#include <SDL/SDL.h>
#include <stdlib.h>
int main ( int argc, char **argv ){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

Sorry I couldnt be more of a help. You may want to run your program through
gdb to see where it is actually unhappy, i.e.,
jclark gerbilater ~/testc) gdb a.out
(gdb) run
Starting program: /home/jclark/testc/a.out
[New Thread 1075626624 (LWP 9810)]

Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 1075626624 (LWP 9810)]
0xffffe002 in ?? ()
(gdb) bt
#0 0xffffe002 in ?? ()
#1 0x40710c05 in esd_open_sound () from /usr/lib/
#2 0x40028491 in SDL_FreeWAV () from /usr/lib/lib
#3 0x40023bd3 in SDL_AudioInit () from /usr/lib/l
#4 0x40022afb in SDL_InitSubSystem () from /usr/l
#5 0x40022b77 in SDL_Init () from /usr/lib/libSDL
#6 0x08048542 in main ()
#7 0x42015574 in __libc_start_main () from /lib/t
(gdb) Quit
(gdb) quit
The program is running. Exit anyway? (y or n) y
jclark gerbilater ~/testc)

Cheers,
Jason.

P.S. Anyone notice the broken pipe above? I am at work and can’t spend too
much debug time, so if anyone recognizes that off the top of their heads,
I’d be interested in finding out what that was about. Thanks!!!> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
TomT64
Sent: Thursday, March 25, 2004 1:07 PM
To: sdl at libsdl.org
Subject: Re: [SDL] 8-line SDL program seg faults!

Millaway, John wrote:

The following program seg faults after SQL_Quit(). Anyone have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

-John


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

— “Millaway, John” <John_Millaway at ghrsystems.com>
wrote:

The following program seg faults after SQL_Quit().
Anyone have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c
    sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

-John

You’ve tested it on all these platforms?

It compiled and ran fine for me… using both
sdl-config --libs and sdl-config --static-libs.

get a backtrace (gdb segfault, then ‘run’, then ‘bt’)
to find out exactly what’s segfaulting.

I suspect you’re missing some library or something,
and SDL dosn’t check it correctly and return with an
error code… or something.

You’re sure it’s after the SDL_Quit?__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.

— Michael Rickert <@Michael_Rickert> wrote:

— “Millaway, John” <John_Millaway at ghrsystems.com>
wrote:

The following program seg faults after SQL_Quit().
Anyone have a clue why?

/* To compile:

  • gcc sdl-config --cflags segfault.c
    sdl-config --static-libs
    */

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

It occurs on Linux, Mac OS X, and FreeBSD.

-John

You’ve tested it on all these platforms?

It compiled and ran fine for me… using both
sdl-config --libs and sdl-config --static-libs.

get a backtrace (gdb segfault, then ‘run’, then
’bt’)
to find out exactly what’s segfaulting.

I suspect you’re missing some library or something,
and SDL dosn’t check it correctly and return with an
error code… or something.

You’re sure it’s after the SDL_Quit?

Also, I should note I’m using 1.2.6 installed from rpms.__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.

Hi all !

Is there any tutorial, demo, game, … where i can look for some code to do
some
sprite animation with SDL and openGL. Now i have a demo using SDL and
sprites
but i would like to test my platform converting this demo to use the 3D
capabilities
same.
Maybe glSDL ?

Any help is welcome,
Jorgefrom my openGL card to know if i can get more rendering speed to do the

-----BEGIN PGP SIGNED MESSAGE-----On Friday 26 March 2004 06:51 am, jorgefm at cirsa.com wrote:

Is there any tutorial, demo, game, … where i can look for some code to do
some
sprite animation with SDL and openGL. Now i have a demo using SDL and
sprites

Off the top of my head I can’t think if any that would walk you through
`glSDL’, but here are some that may point you in the right direction.

http://www.libsdl.org/tutorials.php
http://www.libsdl.org/opengl/index.php
http://sdldocs.csn.ul.ie

Have fun,


  • -Juan D. Espinoza

"Happiness makes up in height for what it lacks in length."
Robert Frost

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv

iQCVAwUBQGRMHEagrZ9eMssBAQG8zgP/R9hIN7dz4mXDRukZzGPb9LZQsLJ+9ZMW
wzlhiV2UMsb7wBOqaduGLYtE+fc2DAElEce9Y+LQbLofzw45O0Ebs7FQucGs9ZCy
n0JA0aCpGTp7FjU31dym3emeTclOBhY2VQIAkgSK/ndfzofnd8BhzqzhcAgHniIm
S1g3H6Jkdqk=
=JPgJ
-----END PGP SIGNATURE-----

Hi all !

Is there any tutorial, demo, game, … where i can look for some
code to do some
sprite animation with SDL and openGL. Now i have a demo using SDL
and sprites
but i would like to test my platform converting this demo to use
the 3D capabilities
the same.

You most probably will get faster rendering with OpenGL, even if
you’re using a fully accelerated 2D backend now. (Don’t ask me why…
Probably something to do with 2D acceleration being out of fashion or
something.)

More importantly, perhaps; you’ll also get loads of new rendering/fx
possibilities, and pretty much all of it will be fully accelerated
wherever there is accelerated OpenGL at all. (As opposed to SDL 2D
alpha blending, which is only h/w accelerated by two or three
backends, including glSDL.)

Maybe glSDL ?

Well, that’s certainly the easiest solution, since you don’t really
have to do anything with your code to use it. It’s still the SDL 2D
API; just a different backend. (Or compile time wrapper, in the case
of the currently available versions.)

That’s also the flip side; it’s still the SDL 2D API. That is, the
only blending mode available is alpha (no additive blending, no color
modulation or anything like that), and there are no transformations
(scaling, rotation, skewing, perspective, …) or other “effects”,
beyond what you can do with the plain SDL 2D API.

If you want to go for the Real Thing (native OpenGL), all I have to
offer in the way of examples would be the smoothscroll example.
That’s really about sub-pixel accurate rendering for ultra smooth
scrolling, but adding sprites should be trivial. Just copy the tile
rendering code and add support for surfaces with alpha channel.

http://olofson.net/examples.html	(smoothscroll)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 26 March 2004 15.51, jorgefm at cirsa.com wrote:

from my openGL card to know if i can get more rendering speed to do

Millaway, John wrote:

Try this instead:

#include "SDL.h"
int main ( int argc, char *argv[] ){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

That won’t help. The seg fault is somewhere deep in the guts of an `atexit’
routine installed somewhere by SDL audio.

This program doesn’t crash for me, not even randomly.
Is it possible that you’re hit by the “signal 0 handler” bug from
12/02/2004 ? Does it work with latest SDL cvs ?

Stephane

Try this instead:

#include "SDL.h"
int main ( int argc, char *argv[] ){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

That won’t help. The seg fault is somewhere deep in the guts of an
`atexit’
routine installed somewhere by SDL audio.

Is this being compiled with MSVC++ .Net? If so, I faced a similar-sounding
problem long ago – noone was ever able to tell me exactly why, but I
believe it has something to do with the SDL Parachute, as calling SDL_Init()
with SDL_NO_PARACHUTE is a hack which seems to “fix” the problem. You might
want to try this, even if you’re not using MSVC++ .Net, and see if it helps.

  • Silicon

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.619 / Virus Database: 398 - Release Date: 3/10/2004

----- Original Message -----
From: john_millaway@ghrsystems.com (Millaway, John)
To:
Cc:
Sent: Thursday, March 25, 2004 9:36 PM
Subject: RE: [SDL] 8-line SDL program seg faults!

Is this being compiled with MSVC++ .Net? If so, I faced a similar-sounding
problem long ago – noone was ever able to tell me exactly why, but I
believe it has something to do with the SDL Parachute, as calling SDL_Init()
with SDL_NO_PARACHUTE is a hack which seems to “fix” the problem. You might
want to try this, even if you’re not using MSVC++ .Net, and see if it helps.

With MSVC 7.1 you must use a sdl.dll linked with msvcr71.dll instead of
msvcrt.dll. Had you tried that? (ie. compiling your own sdl.dll)
Anyway, (the other) John said the seg fault occured on Linux, MacOS X and
FreeBSD.–
Hibernatus

Millaway, John wrote:

#include "SDL.h"
int main (int argc, char** argv){
if (SDL_Init (SDL_INIT_AUDIO) == -1)
exit (-1);
SDL_Quit ();
printf (“Returning…\n”);
return 0;
}

Works fine on my Windows box, VC7.1 and MinGW, debug and release build.
However, the following produces a blue screen of death:

#include “SDL.h”

int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(640, 480, 32, SDL_OPENGL | SDL_FULLSCREEN);
SDL_Quit();
}

Not sure if these crashes are related. Note that real SDL/OpenGL programs
with event loops and rendering code work just fine.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com