#include %26lt;signal.h%26gt;
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
#include %26lt;sys/types.h%26gt;
void segment_fault_handler(int x)
{
*((int *)((int)(%26amp;x))+0)=x;
printf("line 17");
}
int main()
{
int r2 = 0;
signal(SIGSEGV, segment_fault_handler);
r2 = *( (int *) 0 );
printf("Ran instruction\n");
return 0;
}
this compiles and but when i try to run the .exe file i get a segmentation fault error, it does print out "Line 17" once, can someone please try to help debug this.
Can some one with this C code???
it looks like it is doing exactly what you want it to do.
Trying to dereference the null pointer will case a seg fault. That's handled but your handler doesn't really do anything so the program will still crash. You can't just return to where the error occurred.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment