Request for help: SDL game seqfaults in Linux

Greetings!

I’ve got my newest game almost ready: part of the music missing only. I
have developed it on Windows using Dev-C++ IDE with MinGW. It works
great in Windows.

However, every time I’ve tried to make it run on Linux, all I got is a
segfault on SDL_Init(). I’ve backtraced it and it has something to do
with threads, but I don’t quite get it. The funny thing is that I use
exactly the same initialization code in my other game, Formido - which
works all right. I’ve tried it on Mandrake 9.1 and Redhat 9 with the
same result - a segmentation fault.

Now I have packaged the sources with a makefile, and put it ot the
Internet. I request you Linux/SDL users to try it. It builds ok, if you
have SDL and SDL_Image correctly installed. As the game isn’t released
yet (musics not complete), I won’t distribute the data files quite yet.

Now, if you find time to download the sources, build them and try to run
it I’d be grateful. Maybe it’s just my machine that segfaults, I don’t
know. So if you get a segfault, I’m out of luck - unless somebody can
fix it somehow. On the other hand, if you get a sane error about missing
data, it works. Please report all successful efforts to me (tell the
distro you used) and if you can fix the problem it’d be great.

Here’s the link: http://koti.mbnet.fi/lsoft/Delirium/delirium_src.tar.gz

(btw, I’d appreciate if you won’t distribute/hack those sources, as the
game isn’t yet released… After the release - feel free to do what you
want :slight_smile:
Thank you in advance!–
Mika Halttunen
@Mika_Halttunen

Hi!
If you remove SDL_INIT_TIMER in the SDL_Init() function it won’t segfault.

Markku Halttunen wrote:>Greetings!

I’ve got my newest game almost ready: part of the music missing only. I
have developed it on Windows using Dev-C++ IDE with MinGW. It works
great in Windows.

However, every time I’ve tried to make it run on Linux, all I got is a
segfault on SDL_Init(). I’ve backtraced it and it has something to do
with threads, but I don’t quite get it. The funny thing is that I use
exactly the same initialization code in my other game, Formido - which
works all right. I’ve tried it on Mandrake 9.1 and Redhat 9 with the
same result - a segmentation fault.

Now I have packaged the sources with a makefile, and put it ot the
Internet. I request you Linux/SDL users to try it. It builds ok, if you
have SDL and SDL_Image correctly installed. As the game isn’t released
yet (musics not complete), I won’t distribute the data files quite yet.

Now, if you find time to download the sources, build them and try to run
it I’d be grateful. Maybe it’s just my machine that segfaults, I don’t
know. So if you get a segfault, I’m out of luck - unless somebody can
fix it somehow. On the other hand, if you get a sane error about missing
data, it works. Please report all successful efforts to me (tell the
distro you used) and if you can fix the problem it’d be great.

Here’s the link: http://koti.mbnet.fi/lsoft/Delirium/delirium_src.tar.gz

(btw, I’d appreciate if you won’t distribute/hack those sources, as the
game isn’t yet released… After the release - feel free to do what you
want :slight_smile:
Thank you in advance!

Hi!
If you remove SDL_INIT_TIMER in the SDL_Init() function it won’t segfault.

Well, I need SDL_INIT_TIMER because I’m using a timer in the game. I’m in
Windows at the moment, so I cannot try it, but I suspect there’s gonna be
problems if I remove SDL_INIT_TIMER. Formido, the another SDL-game of mine
uses SDL_INIT_TIMER also.

Any more thoughts?

Thank you anyway.–
Mika Halttunen
@Mika_Halttunen

I split the init in two lines:
SDL_Init(SDL_INIT_VIDEO)

SDL_InitSubSystem(SDL_INIT_TIMER) <- segfault

So it’s that timer code that fails somehow… Hmm…

I tried a tiny testapp with just SDL_Init Video and Timer and opening a
screen, thats fine. This means, basically timer does work at least on my
Linux box with my SDL (1.2.6), so the culprit must be somewhere in your
code.

I can also run other SDL_INIT_VIDEO|SDL_INIT_TIMER programs easily, for
example the other game of mine I mentioned. This is strange, indeed.
Maybe it’s a compiler bug? Or SDL bug that is triggered in some rare
conditions?
Thanks guys, for your help so far.–
Mika Halttunen
@Mika_Halttunen

Maybe it’s a compiler bug?

I compiled with g++ 3.3 (unstable) and and 3.2 (stable). Quite unlikely.
Actually, why g++? Compiling with gcc failed, i got some wired linker
errors, probably there is some C++ code inside somewhere.

Peter

PS: Oops, sent my previous mail only to you, not the list. Too stupid to
operate an email client. :*)Am So, den 12.10.2003 schrieb Markku Halttunen um 12:04:

Maybe it’s a compiler bug?

I compiled with g++ 3.3 (unstable) and and 3.2 (stable). Quite unlikely.

Well, I was just thinking out aloud :slight_smile:

Actually, why g++? Compiling with gcc failed, i got some wired linker
errors, probably there is some C++ code inside somewhere.

Ehm… the whole game is coded in C++. At least was when I last looked ;)–
Mika Halttunen
@Mika_Halttunen

Okay, do you have the data files out for download so I can test it?

Markku Halttunen wrote:>>Hi!

If you remove SDL_INIT_TIMER in the SDL_Init() function it won’t segfault.

Well, I need SDL_INIT_TIMER because I’m using a timer in the game. I’m in
Windows at the moment, so I cannot try it, but I suspect there’s gonna be
problems if I remove SDL_INIT_TIMER. Formido, the another SDL-game of mine
uses SDL_INIT_TIMER also.

Any more thoughts?

Thank you anyway.


Mika Halttunen
lsoft at mbnet.fi


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

Okay, do you have the data files out for download so I can test it?

Nope, not yet. Btw, I tried to drop out the SDL_INIT_TIMER, and on my
machine it
doesn’t even get to the missing icon - error message. It still segfaults.
And it
wouldn’t work because I’m using timers anyway.–
Mika Halttunen
@Mika_Halttunen

ok, well… I got missing icon messages that’s why I asked if you got
the data files for download.

Markku Halttunen wrote:>>Okay, do you have the data files out for download so I can test it?

Nope, not yet. Btw, I tried to drop out the SDL_INIT_TIMER, and on my
machine it
doesn’t even get to the missing icon - error message. It still segfaults.
And it
wouldn’t work because I’m using timers anyway.


Mika Halttunen
lsoft at mbnet.fi


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

ok, well… I got missing icon messages that’s why I asked if you got the
data files for download.

Did you got there without removing SDL_INIT_TIMER? If so, then how?
But if it’s because you removed SDL_INIT_TIMER, it’s useless to try with the
data, 'cos the timers wouldn’t work.

Thanks!–
Mika Halttunen
@Mika_Halttunen

I removed the SDL_INIT_TIMER, but I haven’t used timers before so I
don’t know how they work. If I get some more free time I can look into
it more and see if I find a solution for the problem.

Markku Halttunen wrote:>>ok, well… I got missing icon messages that’s why I asked if you got the

data files for download.

Did you got there without removing SDL_INIT_TIMER? If so, then how?
But if it’s because you removed SDL_INIT_TIMER, it’s useless to try with the
data, 'cos the timers wouldn’t work.

Thanks!

Mika Halttunen
lsoft at mbnet.fi


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

I’d like to try to compile and run your sourcecode, however since you
use fmod, which is not available for my platform (OS X), I can’t.

Well you could modify the makefile not include any FMOD stuff, compile
and comment out all the errors/warnings that arise. Taking out the FMOD
calls from ‘fmod_playlist.cpp’ and ‘init.cpp’ would do if I remember
correctly :slight_smile:

I’ll offer some tips nonetheless:

  • you don’t do a SDL_INIT_EVERYTHING. It is possible (albeit perhaps
    improbable) that some timer code depends on the initialization of the
    audio subsystem (using the soundcards timers).

Yeah, but it doesn’t probably help in this case, as I at some point of
development had SDL_INIT(video + audio + timer) there. Since I was using
FMOD to handle audio, I took SDL_INIT_AUDIO out. It didn’t seem to hurt
anything if it was there, though. But then again, on Windows you won’t
probably even notice if there is bad stuff happening under the hood.

  • after you do your SDL_Init, you call atexit(SDL_Quit). This is
    superfluous; on a crash, the SDL parachute will be dropped, and on
    normal exit, you should just run SDL_Quit yourself.

Good point, thanks.

  • if/when you release your source under the GPL, you’ll have to make a
    special exception to the GPL (because of fmod, which is not

GPL-compatible).
Thanks for this info - I’m not that good in these license issues. Would it
suffice if I added that “In addition, as a special exception, …” - stuff
to my license and source files?

Thanks for your tips.–
Mika Halttunen
@Mika_Halttunen

At 07:41 PM 12/10/2003 +0300, you wrote:

I’d like to try to compile and run your sourcecode, however since you
use fmod, which is not available for my platform (OS X), I can’t.

Well you could modify the makefile not include any FMOD stuff, compile
and comment out all the errors/warnings that arise. Taking out the FMOD
calls from ‘fmod_playlist.cpp’ and ‘init.cpp’ would do if I remember
correctly :slight_smile:

Ok. Ive given it a try and got a segfault. If I compile this program,
link and execute I dont get a segfault:

int main(int argc, char *argv[])
{
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
printf(“Unable to init SDL: %s”, SDL_GetError());

 SDL_Quit();

}

However if I comment your program down to just those lines then I do get
a segfault. That would seem to me to indicate it was something you are
linking with. But I took out -lm (whatever that did!) and -lfmod by
commenting out huge chunks and still I get a segfault. I cant see what you
are linking with that is causing the troubles. Sorry I couldnt be more
help but linking is the only reason I can see that identical code would
cause problems in 2 different programs.

Neil.

segfault. I cant see what you are linking with that is causing the
troubles. Sorry I couldnt be more help but linking is the only reason I
can see that identical code would cause problems in 2 different programs.

Ive worked solid on this one for an hour or two and by stubbing out code
and stuff like that (slowly taking files out and adding them in to the
compile until I found the cause of the segfault) I have solved this
thing. To fix it:

Rename the array “pipe” in game.cpp to anything else, I went with “pipe2”.

This is clearly an obscure mis-linking with some Linux libs using a global
variable named pipe, but simply renaming that removes the segfault on
mine. I really hope that solves it for everyone! If anyone else that
downloaded the code could confirm it that would be good. Ive attached the
modified game.cpp to help with that.

Neil.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: game.cpp
Type: application/octet-stream
Size: 10278 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20031012/44326945/attachment.obj

Confirmed. I changed the name to “apipe” and the segfault is now gone.
Good detective work :wink:

JeffOn Sunday 12 October 2003 11:16 am, Neil Brown wrote:

Rename the array “pipe” in game.cpp to anything else, I went with “pipe2”.

I really hope that solves it for everyone! If anyone else that
downloaded the code could confirm it that would be good.

Confirmed. Works.

Wired bug. Excellent detective work, Sherlock! :*)
I am usually a strong Linux advocate, but if anyone here would mention
something like “What a crap!” I need to silently agree…

PeterAm So, den 12.10.2003 schrieb Neil Brown um 20:16:

I really hope that solves it for everyone!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!Am Sonntag, 12. Oktober 2003 22:00 schrieb Peter Strempel:

I am usually a strong Linux advocate, but if anyone here would mention
something like “What a crap!” I need to silently agree…
Well, it is probably not even the fault of linux, but of the compiler/linker.


Matthias Bach | GPG/PGP-Key-ID: 0xACA73EC9
www.marix-world.de | On Keyserver: www.keyserver.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/icAXlnJmS6ynPskRApahAJ4pGGQRdZPYSyHY7gT7q8EDlugztwCfS2OT
J3b66MtwSMGNnFdoB7kjUNM=
=TbtQ
-----END PGP SIGNATURE-----

Neil Brown wrote:

Ive worked solid on this one for an hour or two and by stubbing out code
and stuff like that (slowly taking files out and adding them in to the
compile until I found the cause of the segfault) I have solved this
thing.

Neil, thank you very much! That must have been real pain to find it.
Interestingly, I found similiar compiler bug one time when I was
developing an OpenGL game with MSVC++ 6. During some point of the
development, one texture stopped working, i.e. showed up all white while
running. After days of trying different approaches, I just renamed the
variable that hold the texture: it worked. These are nasty things,
that’s for sure =)

I have yet to try it myself, but judging from the success reports of
the others, I think it will work on my box too! Again, cheers for Neil
and others too!

Thank you!–
Mika Halttunen
@Mika_Halttunen