top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to debug a segmentation fault with NO '-g' compiled binaries or libraries

0 votes
458 views

How can we debug the segmentation fault in a program which has been compiled without "-g" option?

posted Jul 17, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Insert some fprintf s, fflush s and checks for NULL in the code and explicit initialize its variables.
If the program is running on Linux, set /proc/sys/vm/overcommit_memory appropriately.

answer Jul 17, 2013 by anonymous
Similar Questions
0 votes

Following is my code and getting segmentation fault. Please help

#include<stdio.h>
#include<string.h>
main()
{
    char *p,str[100]="Hi, How Are You, Fine, Thank You";
    p=strtok(str,",");
    printf("%s\n",p);
    while(p != NULL)
    {
        p=strtok(NULL,",");
        printf("%s\n",p);
    }
}

O/p is:
Hi
How Are You
Fine
Thank You
and then Segmentation fault.

+4 votes

I have written print("%s", __LINE__); I get crashed. Can someone please explain why it is happened ?

...