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?
            Asked
            
        
        
            Active
            
        
            Viewed 2.1k times
        
    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
- 
                    1Run the program in a debugger, so that you will break when the fault happens. – unwind Mar 07 '13 at 13:48
- 
                    1Are 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 Answers
7
            
            
        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
and to allow daemons dump core:
setsebool -P daemons_dump_core 1
 
    
    
        Oleg Neumyvakin
        
- 9,706
- 3
- 58
- 62
 
    
    
        Maciek B
        
- 394
- 1
- 7
- 
                    1My `/proc/sys/fs/suid_dumpable` puts out `2`, and I cannot find `getsebool`. What can I do? – Alejandro Galera May 29 '18 at 15:47
- 
                    @AlejandroGalera From https://man7.org/linux/man-pages/man2/prctl.2.html "Between kernels 2.6.13 and 2.6.17, the value 2 was also permitted, which caused any binary which normally would not be dumped to be dumped readable by root only; for security reasons, this feature has been removed." – Oleg Neumyvakin May 23 '23 at 06:41
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
        
- 72,253
- 8
- 102
- 198
- 
                    2+program is a daemon, but OP changes ulimit setting for his current shell session. – Slava Mar 07 '13 at 13:57
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
        
- 7,378
- 4
- 37
- 54
-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,113
- 1
- 21
- 31
