Possible causes of a segmentation fault?
Ok, I've got a segmentation fault error on a PS2. I'm not quite sure what the problem is. The PS2 Linux kit is infamous for its lack of debugging tools so all I can do is use printfs to find the problem. It looks like the error is tied to a "new"ed (dynamically allocated) array of a class which contains a matrix class which includes a float[16] variable. I'm really shooting in the dark at the moment. Any ideas/tips?
Stuff like that:
float omg=*(float*)0; // Reading/writing from/to a memory location you shouldn't.
will cause a segmentation fault.
float omg=*(float*)0; // Reading/writing from/to a memory location you shouldn't.
will cause a segmentation fault.
I seg fault all the time - it's my boss's fault. I'll be sitting there coding, then he'll ping me on IM w/ "Do you are it's working?"
I just blink a few times, then have to reboot.
I just blink a few times, then have to reboot.
It might be helpful to catch the segfault signal with your own handler and not the default one that just terminates the program.
[Edited by - snisarenko on December 3, 2005 7:02:23 PM]
#include <signal.h>void handler(int signo){ //you handling code goes here}int main(){ struct sigaction segfaultaction; /*initialize the action*/ segfaultaction.sa_handler = handler; if(sigemptyset(&segfaultaction.sa_mask)<0) { printf("Error filling a sigset\n"); return -1; } tickaction.sa_flags=0; if(sigaction(SIGSEGV,&segfaultaction,NULL)<0) { printf("Error setting action\n"); return -1; }}
[Edited by - snisarenko on December 3, 2005 7:02:23 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement