≡ Menu

core dumps

Core dumps are often used to diagnose or debug errors in Linux or UNIX programs. Core dumps can serve as useful debugging aids for sys admins to find out why Application like Lighttpd, Apache, PHP-CGI or any other program crashed. Many vendors and open source project author requests a core file to troubleshoot a program. A core file is generated when an application program abnormally terminates due to bug, operating system security protection schema, or program simply try to write beyond the area of memory it has allocated, and so on. This article explains how to turn on core file support and track down bugs in programs.
[click to continue…]

A debugger is a computer program that is used to test and debug other programs. Both sys admin and developers may use debugger to examine code or halt instructions when specific conditions are encountered using an instruction set simulator (ISS).

The GNU Debugger (GDB) is used as debugger for the GNU software. It is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, and C++.

Debugging, the demanding process of finding and fixing programming errors, is fundamental to successful software development. But even many experienced programmers find debugging a challenge.

The Art of Debugging with GDB, DDD, and Eclipse (No Starch Press, September 2008, 280 pp, ISBN 9781593271749) teaches readers how to effectively use the three most popular open source debugging tools:

  • GDB
  • DDD
  • Eclipse

The text-command based GDB is included with most Linux distributions. DDD is a popular GUI front end for GDB, while Eclipse provides a complete integrated development environment.

In the book, readers learn how to:

  • Inspect variables and data structures
  • Understand segmentation faults and core dumps
  • Use features like catchpoints, convenience variables, and artificial arrays
  • Avoid common debugging pitfalls
  • Prevent errors in the first place by making the best usage of editors, compilers, and static code checkers

The book also includes coverage of advanced topics like thread, client-server, GUI, and parallel programming. Whether readers dread the thought of debugging programs or simply want to improve their current debugging efforts, they'll find a valuable ally in The Art of Debugging with GDB, DDD, and Eclipse.

The book is written by Norman Matloff - a computer science professor at UC Davis and Peter Jay Salzman who is currently a programmer with a Wall Street financial firm. The authors are well-known for their popular online debugging tutorials, and a printed book is long overdue.

The Art of Debugging offers readers specific advice for debugging with each tool and explains general debugging strategies. Real world examples of coding errors help to clarify the authors' guiding principles, and readers will quickly understand why their programs crash or throw exceptions.

Book Information

  • Publisher: No Starch Press
  • Pub date: September 2008, 280 pp
  • ISBN: 9781593271749
  • Price: $39.95 USD
  • Order Info: order@oreilly.com / 1-800-998-9938 / 1-707-827-7000 / Oreilly web store
  • Support nixcraft: Order book from Amazon

Recently I have noticed that my Apache error log file shows it is generating segmentation faults. After doing little research I came to know that there is not simple solution to find of causes of this problem. I got an error that read as follows:

[Mon May 8 11:20:09 2006] [notice] Apache/2 (WebAppBETA) child pid 1256 exit signal Segmentation fault (11)
[Mon May 8 11:23:12 2006] [notice] Apache/2 (WebAppBETA) child pid 1301 exit signal Segmentation fault (11)

The problem is that our application development team has hacked (aka modified source code) Apache 2.0 source tree for application my company developing. To get rid of this problem I was asked to configure a Linux system so that Apache can dump core files on segmentation faults.

Apache Core Dump

Apache supports CoreDumpDirectory directive. This controls the directory to which Apache attempts to switch before dumping core. So all I need to do is put line as follows in httpd.conf:

Open httpd.conf:
# vi httpd.conf
Add following line main config section:
CoreDumpDirectory /tmp/apache2-gdb-dump
Create a directory /tmp/apache2-gdb-dump:
# mkdir -p /tmp/apache2-gdb-dump
Set permission:
# chown httpd:appserver /tmp/apache2-gdb-dump
# chmod 0777 /tmp/apache2-gdb-dump

Please note that we are using httpd user and group appserver. Please replace it with your actual Apache user:group combination.

And restart the Apache web server:
# /etc/init.d/httpd restart
OR kill Apache PID:
# kill -11 14658
Now you should see core dumps in /tmp/apache2-gdb-dump directory:
# ls /tmp/apache2-gdb-dump

How do I read the core dump files created by Apache on Linux systems?

Well I am not a developer but they are using gdb and other techniques to analyses the core dumps. Read man page of gdb for more information.

I hope that I will get a new patched version of Apache by next week. Another interesting fact I noticed that you need to configure Core Dumps on Linux only. We are also using FreeBSD for testing and it write core dump in the ServerRoot directory.

If Apache starts as root and switches to another user, the Linux kernel disables core dumps even if the directory is writable for the process. Apache (2.0.46 and later) enables core dumps on Linux 2.4 and beyond, but only if you explicitly configure a CoreDumpDirectory. :)