Troubleshooting Lighttpd Chrooted RedHat PHP Version 5.1.6-20.el5_2.1

Posted on in Categories CentOS, GNU/Open source, kernel, lighttpd, Linux, Linux distribution, php, RedHat/Fedora Linux, Troubleshooting last updated October 1, 2008

It appears that latest php version 5.1.6-20.el5_2.1 under RHEL / CentOS Linux v5.2 has made some major changes. As a result choort jail setup using previous instructions no longer works. PHP is crashing with segmentation fault errors. So I had to trace php errors using strace command.

Why Does The Segmentation Fault Occur on Linux / UNIX Systems?

Posted on in Categories C Programming, CentOS, Debian Linux, fedora linux, GNU/Open source, Hardware, Linux, Linux distribution, RedHat/Fedora Linux, Sys admin, Troubleshooting, Ubuntu Linux, UNIX last updated September 12, 2008

An error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. Here are few tips to track down “Segmentation Fault” error under UNIX / Linux.

valgrind – Linux Tools For Debugging And Profiling Programs ( bug reporting tool )

Posted on in Categories Hardware, Howto, Linux, Sys admin, Troubleshooting last updated April 15, 2008

Few days back I wrote about strace tool for reporting and finding bug in program. Today I’m going to talk about another interesting tool called valgrind.

Valgrind is a flexible program for debugging and profiling Linux executables. It consists of a core, which provides a synthetic CPU in software, and a series of “tools”, each of which is a debugging or profiling tool. The architecture is modular, so that new tools can be created easily and without disturbing the existing structure. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

The Valgrind distribution currently includes five production-quality tools:

  • a memory error detector
  • a thread error detector
  • a cache and branch-prediction profiler
  • a call-graph generating cache profiler
  • a heap profiler

It also includes two experimental tools:

  • a data race detector
  • an instant memory leak detector.

It runs on the following platforms:

  • X86/Linux
  • AMD64/Linux
  • PPC32/Linux
  • PPC64/Linux

How do I use valgrind?

Valgrind is typically run as follows:
$ valgrind command-name arg1 arg2 argN
$ valgrind program args
$ valgrind ./myapp -d /tmp -f 120

You can select tool using the –tool=TOOLName option. For example use memcheck which is a fine-grained memory checker. To generate trace back for command called myapp, enter:
$ valgrind --tool=memcheck -v --log-file=myapp.dbg --num-callers=8 ./myapp -d /tmp -f 120
Where,

  • –tool=memcheck : Run the Valgrind tool called memcheck
  • -v : Verbose output
  • –log-file=myapp.dbg : Specifies that Valgrind should send all of its messages to the specified file.
  • –num-callers=8 : By default, Valgrind shows twelve levels of function call names to help you identify program locations. You can change that number with this option. This can help in determining the program’s location in deeply-nested call chains.

The –leak-check option turns on the detailed memory leak detector:
$ valgrind --tool=memcheck -v --log-file=myapp.dbg --num-callers=8 --leak-check=yes ./myapp -d /tmp -f 120

Further readings: