Search code examples
gdbqnx

How can I go about debugging this SIGSEV in gdb?


I am building previously working code, but I am getting a seg fault and I can't figure out what went wrong. gdb catches the error, but it doesn't point to an obvious cause. The source line it shows is a function name, so it doesn't even get into the function. If I look at the dissasembly of the instruction it is still setting up the stack, so maybe the stack is messed up. So how should I go about debugging this? This is in QNX 6.2, console gdb only.

0x0816b829 in __ml (this=0x79b963c, anMultiplier=0) at ../u_matrix.cpp:56
56      tcMatrix tcMatrix::operator*(float64 anMultiplier)

0x816b820 <__ml>:       push   %ebp
0x816b821 <__ml+1>:     mov    %esp,%ebp
0x816b823 <__ml+3>:     sub    $0x13ac,%esp
0x816b829 <__ml+9>:     push   %edi
0x816b82a <__ml+10>:    push   %esi
0x816b82b <__ml+11>:    push   %ebx 

Solution

  • The instruction you are crashing on is push %edi.

    This most likely means that you have a stack overflow.

    One likely cause of stack overflow is infinite recursion. If (gdb) where shows unending stream of function calls, that's your problem.

    If where shows reasonable sequence of calls, execute info frame and up repeatedly, looking for frames with unreasonably large size.

    Finally, the problem may be caused by a change in your execution environment, and not by anything in your program. I am not sure what QNX equivalent of ulimit -s is, but it's possible that your stack limit is simply too small.