🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL Crash on exit

Started by
7 comments, last by Kylotan 19 years, 11 months ago
Everything seems to work ok, but when quitting from the program it crashes. Both exit(0) and returning from the main cause the crash. I have a similar kind of project with all same settings etc., but it doesn't crash.
Advertisement
Have you managed to trap the crash in the debugger?

If its crashing on exit, then its most likely in a destructor at the global level.
This seems to be a common problem new people have with SDL.
Here is a check list you can go through.
1) did you call SDL_Quit?
2) did you free all of your surfaces? sounds?
3) did you accidently free the screen?

those seem to cause alot of crashes...
otherwise, it could be some of your code.

Is it a c or c++ program?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
I did everything all right, but forgot something much important: SDL_Init()! The damn thing runs without that...
LOL!

Were you just doing a dry run without creating a window or graphics?

Thats great. [totally]
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Quote: Original post by PnP Bios
Were you just doing a dry run without creating a window or graphics?


Actually setting the video mode opens the window. Like I said everything (graphics too) was working nicely until exit. Apparently something is set in SDL_Init which then is processed in SDL_Quit and if SDL_Init is missing the it's crash time..
Now I noticed that SDL deploys a "parachute" because of a segmentation fault (reported in stderr.txt). It went unnoticed because the source directory has so many files. How can I fix that?
I managed to track down the cause for SDL seg fault: free() -functions. Somehow gdb "can't load the executable", but I wrote a function which writes some text to a file and after one free() it won't write the file. What's wrong with free()s? All free's have their malloc-counterpart, nothing is missing.
Perhaps you're scribbling over the boundaries of the memory you're trying to free.

This topic is closed to new replies.

Advertisement