Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

Why there is no core file when a Segmentation fault occured!

I have a program, i can debug with the core file  when a segmenttation fault occured, but how can i debug when there is no core file?
0
sandy_wu
Asked:
sandy_wu
  • 2
  • 2
1 Solution
 
BlackDiamondCommented:
If you're using gdb, you can step through the program line by line to see where it bombs.  You can also use breakpoints if it is a large app (to narrow down the location).  

Also, a good practice is to write wrappers around anything that deals with memory (malloc, calloc, realloc, etc.) that do error checking and give useful errors.

If your wrappers don't catch the errors, then you can narrow it down to pointer math errors.  Then use a debugger (or print statements if you have to) to pinpoint the location in your app.
0
 
sandy_wuAuthor Commented:
Thank U BlackDiamond, but what I mean is Why there is no core file when a Segmentation fault occured? and sometime it has!
0
 
BlackDiamondCommented:
Sorry, I didn't look at the question in the header.  It is probably because the core file generated would be larger than your ulimit.  Try the command "ulimit -c unlimited", and see if it generates the cores consistently.

Also, another useful program for debugging is "strace".
0
 
ahoffmannCommented:
use following syntax:

bash% ulimit -c unlimited
 ksh% ulimit -c unlimited
  sh% ulimit -c unlimited
tcsh% limit coredumpsize unlimited
 csh% limit coredumpsize unlimited
keep in mind that this may produce huge core files, which also may take sevaral minutes to complete
0
 
sandy_wuAuthor Commented:
Thank U BlackDiamond, and thank U ahoffmann, both of U are right, and ahoffmann is more detail.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now