How to restore core dumps on Fedora 13

Prepared by Alison Chaiken and offered under cc-by-sa

Motivation

Using tools like gdb to examine core files can be extremely useful in debugging shaky programs on Linux. (My other favorite tools besides gdb for diagnosing crashes are strace and ltrace, which I learned about from Christopher Hallinan.) Frustratingly core files disappeared when abrtd appeared in Fedora, in release 12 if I recall correctly. According to Dave Neary, the traditional and simple "ulimit -c unlimited" is still all that's required to restore core files on Ubuntu, but Fedora expects more of their users.

The source of the problem

abrt is a Fedora system which

semi-automatically provides information about defects and crashes on
user system. It collects necessary data about the crash, generates a
report with all information and based on user interaction sends it to
some bug reporting system.
The problem is, abrtd intercepts user-generated core files, even for the programs the user writes him- or herself. I have no problem with abrtd catching Gnome or Firefox core files, but the fact that my programs don't drop core in directories of my choice is simply unacceptable. Also, I find it very annoying that abrtd requires creation of yet another new account with new credentials. After all, I'm already logged into localhost; why not offer me the choice of sending my username and IP address? Fundamentally, abrtd is simply unacceptable to me, as much as I want to support Fedora debugging. Out it goes.

The situation before steps below

[alison@bonnet ~]$ ulimit -c unlimited
-bash: ulimit: core file size: cannot modify limit: Operation not permitted
[alison@bonnet ~]$ sudo set ulimit -c unlimited
sudo: set: command not found

Step-by-step restoration of core on Fedora 13

  1. Get rid of that annoying abrtd:
    sudo service abrtd stop
    
  2. Just go away abrtd and don't trouble me any more:
    sudo chkconfig --del abrtd
    
  3. Edit /etc/sysctrl.conf and change
    kernel.core_pattern = |/usr/libexec/abrt-hook-ccpp /var/spool/abrt %p %s %u %c
    
    to
    kernel.core_pattern = core
    
  4. Edit /etc/security/limits.conf and add the line
    *  soft  core  unlimited
    
    (Yeah, "soft core". Actually "hard core" is legal too.)
  5. Finally, edit /etc/init.d/functions if necessary:
    	# make sure it doesn't core dump anywhere unless requested
    	corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
    
    That step appears to be unnecessary.
  6. Now create a program that drops core. (I assume that the reader already knows how.)

After steps above

[alison@bonnet ~]$ ulimit -c unlimited
[alison@bonnet kernel_char]$ ./bit_palindrome
Segmentation fault (core dumped)

Finally! A file called core.$PID will be dropped in $CWD. Now the user can "gdb $EXECUTABLE $CORE" to heart's content.