top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

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

0 votes
34 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 Google+ Share Button LinkedIn Share Button Multiple Social 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 ?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...