Jump to content
  • Advertisement
Sign in to follow this  
ecr0n

SDL Help

This topic is 4877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 < 3
for (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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!