6

I am consistently getting a segmentation fault in my program, yet no core dump files are generated. ulimit shows a value of unlimited, did ulimit -c unlimited just to be sure, and it appears to be fine. Any ideas?

OBLE Codemonkey
  • 160
  • 2
  • 2
  • 7
  • Mayby show us some code first? – Blood Mar 07 '13 at 13:47
  • It's most likely a null pointer or accessing outside an array. – QuentinUK Mar 07 '13 at 13:48
  • 1
    Run the program in a debugger, so that you will break when the fault happens. – unwind Mar 07 '13 at 13:48
  • 1
    Are you sure you are looking at proper place? Do you have enough room on that filesystem? – Slava Mar 07 '13 at 13:49
  • Seems to be shell-dependent: http://stackoverflow.com/questions/17965/generate-a-core-dump-in-linux – Bart Friederichs Mar 07 '13 at 13:50
  • @unwind it is not always possible to run a program under debugger. Also program may crash sporadically, ie once per week. Good luck catching that under debugger. – Slava Mar 07 '13 at 13:51
  • @Slava Yes, but the question says "I am consistently getting [...]", hence my suggestion. – unwind Mar 07 '13 at 13:52
  • @BartFriederichs setting limits syntax is shell dependent, how they are handled is not. – Slava Mar 07 '13 at 13:55
  • See: http://stackoverflow.com/questions/7732983/core-dump-file-is-not-generated/18428840 http://stackoverflow.com/questions/6152232/how-to-generate-core-dump-file-in-ubuntu/18428730 http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes – kenorb Aug 25 '13 at 12:13

4 Answers4

6

if your program runs as root (or with root capabilities) check:

cat /proc/sys/fs/suid_dumpable

or if program is a daemon check:

getsebool allow_daemons_dump_core

Maciek B
  • 384
  • 1
  • 7
3

There could be several reasons

  • no write access to the directory
  • the program changes the working directory
    look for the core in other places too
  • disk is full
  • ulimit is set in one shell and the program is started in a different shell or environment
Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188
1

To get around the shell session issue, providing you don't object to being root to test:

#ifdef DEBUG
    // Enable core dumps
    struct rlimit corelim;

    corelim.rlim_cur = -1;
    corelim.rlim_max = -1;

    if (setrlimit (RLIMIT_CORE, &corelim) != 0)
    {
        log_error ("Couldn't set core limit");
    }
#endif
Joe
  • 6,884
  • 4
  • 36
  • 50
-6

the segmentation fault occurs especially that you access the wrong address in memory. It is very possible to have a resource improperly initialized. For example, you can use Valgrind for debugging.

Mihai8
  • 3,023
  • 1
  • 19
  • 29