[gfortran,patch] Allow backtracing non-library errors

FX Coudert fxcoudert@gmail.com
Fri Aug 10 22:58:00 GMT 2007


OK, I've found why I couldn't see it before: it happens on x86_64- 
linux only with -m32.

> So gdb appears to be fine, but it does recognize something that the
> normal backtrace code apparently doesn't.

Yup, somehow the glibc backtrace() function thinks the error happened  
at 0xffffe500, but addr2line can make anything out of that address.  
Somehow, gdb is smarter than that. The following small C testcase  
show this:

$ cat a.c
#include <stddef.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <execinfo.h>

void
handler (int signum)
{
   void *trace[50];
   int depth = backtrace (trace, 50), i;
   char **str;

   str = backtrace_symbols (trace, depth);
   for (i = 0; i < depth; i++)
     printf ("%s\n", str[i]);

   _exit (1);
}

int main (void)
{
   int * foo = NULL;

   signal (SIGSEGV, handler);


   *foo = 42;
   return 0;
}

$ gcc a.c -m64 -g && ./a.out
./a.out [0x40060e]
/lib/libc.so.6 [0x2aeb0d8c2110]
./a.out [0x40067b]
/lib/libc.so.6(__libc_start_main+0xda) [0x2aeb0d8af4ca]
./a.out [0x40052a]

$ gcc a.c -m32 -g && ./a.out
./a.out [0x80484a3]
[0xffffe500]
/lib32/libc.so.6(__libc_start_main+0xd3) [0xf7e0cea3]
./a.out [0x80483d1]



 From my experiments, it's always the top-most frame that is missing  
from the backtrace. I'll post this to the glibc mailing-list, and see  
if there is a workaround.

FX



More information about the Fortran mailing list