Sign in to follow this  
Leo_E_49

Possible causes of a segmentation fault?

Recommended Posts

Leo_E_49    228
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?

Share this post


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

Share this post


Link to post
Share on other sites
snisarenko    526
It might be helpful to catch the segfault signal with your own handler and not the default one that just terminates the program.


#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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this