SDL Help

Started by
4 comments, last by Will F 18 years, 10 months ago
Hello. What does the error message: Fatal signal: Segmentation Fault (SDL Parachute Deployed) mean? I am getting it within the stderr.txt file. It isn't allowing my compiled project to run. Thanks.
Advertisement
Maybe this can help you....

If not, try explaining what are you doing exactly...

Good luck!

Haora
It basically means your program crashed. Probably you used an invalid pointer somewhere - maybe an SDL function returned a NULL pointer but you treated it as if it was valid.
Basically it means you are accessing memory you aren't supposed to. The Wikipedia entry on segmentation fault might be useful.

Example: you create an array with 5 elements, then try to assign a value to the 7th element, you'll get a segmentation fault because you are trying to write to memory you aren't allowed to (the array only has 5 elements).

In SDL I would guess that you are trying to use a NULL pointer. Chances are you have tried to load a image using SDL_LoadBMP() and the load failed. After you try to load an image make sure that the pointer does not equal NULL.

Also, many SDL functions return codes indicating success or failure, whenever you call a function that returns a success value always check that the function was successful.
Quote:Original post by Will F
Example: you create an array with 5 elements, then try to assign a value to the 7th element, you'll get a segmentation fault because you are trying to write to memory you aren't allowed to (the array only has 5 elements).


That wont create a SDL segmentation fault unless you read/write beyond the programs allocated memory, but that's a rare bug. It usually wont crash a program but instead will create completely random bugs that are impossible to find. When i had one of these such bugs it seriously took me three months to find out that my map class was changing my characters names in my game.

here's what i think you should always do to prevent bugs.
1. ALWAYS initiate pointers to zero. and always check to see if they are zero (NULL). This probably your problem.
2.use smart pointers for pointers that are tossed around alot in your program.
3.create a debug mode array class that checks and makes sure you arent tryign to access data outside of your array.

Now I get a cookie!
Quote:Original post by Axenation
That wont create a SDL segmentation fault unless you read/write beyond the programs allocated memory, but that's a rare bug. It usually wont crash a program but instead will create completely random bugs that are impossible to find. When i had one of these such bugs it seriously took me three months to find out that my map class was changing my characters names in my game.


Oops you're right, I was thinking of C++ vectors, where it will cause a segmentation fault (at least on my machine).

I've removed the offending material from the post. Had my mind elsewhere (and needing some caffeine).

Been awhile since I used C style arrays, but this reminds me of the first time I had a bug that took forever to track down. It looked somewhat like:
int foo[3];// should be i < 3for (int i = 0; i <= 3; ++i) {  foo = 55;}


I must have gone brain dead when I wrote that, but since it was in an area of code that was rarely called, tracking it down was a real pain - especially as it was hard to reproduce.

Then again, I rarely use C style arrays anymore and mostly stick with std::vector

[Edited by - Will F on June 14, 2005 3:44:37 PM]

This topic is closed to new replies.

Advertisement