How to predict where segmentation fault occurs if we are increasing a pointer in a infinite loop?
I have thought that we can use the alarm signal handler and it will be invoked after every 1 second and it will print the address pointed to by the pointer so that when the segmentation fault would occur we would get a very nearby address where it occurred.
Could there be more better solution? If there then please tell. Thanks in advance
#define SECOND 1
void ALARMhandler(int sig)
alarm(SECOND); /* set alarm for next run */
signal(SIGALRM, ALARMhandler); /* reinstall the handler */