catchsegv
Debug segmentation faults in programs
SYNOPSIS
catchsegv [-h | -l LENGTH | -o FILENAME]... PROG [ARGS...]
PARAMETERS
-h, --help
Display help message and exit
-l, --length=LENGTH
Set stack trace depth (default: 128 frames)
-o, --output=FILENAME
Write trace to FILENAME instead of stderr
DESCRIPTION
catchsegv is a debugging utility from the GNU C Library (glibc) that intercepts segmentation faults (SIGSEGV) and bus errors (SIGBUS) in dynamically linked programs. It preloads libSegFault.so, which installs a signal handler to capture these faults and generate a detailed stack backtrace instead of letting the program crash silently.
The stack trace displays the call chain with memory addresses, function names (if available), and offsets. This output aids in pinpointing crash locations without a full debugger like GDB. Addresses can be resolved to source lines using addr2line(1) or objdump.
Usage is simple: prefix any command with catchsegv. For example, catchsegv ./myapp runs myapp, and on fault, prints:
*** caught SEGFAULT ***
backtrace(20):
[0] /lib/libc.so.6(+0x12345)[0x789ab]
[...]
This tool is lightweight, requires no recompilation, and works on x86, ARM, and other architectures supported by glibc. It's ideal for quick crash analysis in scripts or production-like environments.
Primarily for glibc-linked binaries; ineffective on static executables or stripped binaries without symbols.
CAVEATS
Unreliable with multi-threaded programs, custom signal handlers, setuid binaries, or statically linked executables.
Requires symbols for meaningful traces; stripped binaries show addresses only.
EXIT STATUS
0: success or normal program exit
1: PROG failed to start
2: catchsegv internal error
EXAMPLE
catchsegv -l 50 -o crash.log ./faulty_app arg1
Captures up to 50 frames in crash.log on fault.
HISTORY
Developed by Ulrich Drepper; introduced in glibc 2.1 (1999) as part of glibc's debugging toolkit. Evolved with glibc for better thread support and architectures.


