PDA

View Full Version : segmentation fault



mikeglaz
06-23-2010, 05:09 PM
My computer was on during a storm and the power went out. Now, any Mesa3D program I try to compile with gcc `pkg-config --cflags --libs glut` myProgram.c -o test, I get a segmentation fault when I try to run the compiled program.

codebreaker
06-24-2010, 05:15 AM
First, check all of your source and config files and ensure that they were not modified since your last successful build. If there were code modifications, look them over very carefully - even a trivial change could have a typo. Presumably you have some source control - go back to a previous known working version and see if the seg fault still occurs.

Second, run the compiler (and linker) with all of the verbose options and make sure there are no errors.

Third, if you have another computer where you can try running the program (or compiling and running) do that. See if the result is the same.

If the compiler executes properly, and there were no changes to your code since a previous compilation which ran successfully, it is hightly unlikely that the problem is due to corruption of the compiler or the source code. This would leave the platform, e.g. something that the program is doing involves a component that was fried in some way, and a resultant failure caused a seg fault (you might check your error handling, but issues with handling this kind of problem could be internal to a library or driver as well).

kowal
06-24-2010, 03:32 PM
I had similar problems (corrupted libs) on my old laptop with failing HDD.
Maybe some sector on yours was accidentally written when power went out?
Reinstall Mesa, graphics drivers and libs You are using (check with ldd your-program).
Check your fs with fsck.