I have a multithreaded C program, which consistently generates a segmentation fault at a specific point in the program. When I run it with gdb, no fault is shown. Can you think of any reason why the fault might occur only when not using the debugger? It's pretty annoying not being able to use it to find the problem!
Segfault only when NOT using debugger
cdebugginggdbsegmentation-fault
Best Answer
Classic Heisenbug. From Wikipedia:
The debugger may be changing timing, and hiding a race condition.
On Linux, GDB also disables address space randomization, and your crash may be specific to address space layout. Try
(gdb) set disable-randomization off
.Finally,
ulimit -c unlimited
and post-mortem debugging (already suggested by Robie) may work.