https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67365

            Bug ID: 67365
           Summary: Spurious address printed in backtrace
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jb at gcc dot gnu.org
  Target Milestone: ---

Following the recent update to use libbacktrace instead of fork+exec of
addr2line in libgfortran, a small test program I had lying around shows a
strange address as the first stack frame. The program:

program bt
  implicit none
  call a
contains
  subroutine c(a, b, res)
    real(8) :: a, b, res
    res = a / b
  end subroutine c

  subroutine b
    real(8) :: res
    call c(0.d0, 0.d0, res)
    print *, res
  end subroutine b

  subroutine a
    call b
  end subroutine a

end program bt

Compile with
$ gfortran -g -ffpe-trap=zero,invalid -o bt2static -static bt2.f90
$ ./bt2static

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic
operation.

Backtrace for this error:
#0  0x43056f in ???
#1  0x40118d in c
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:7
#2  0x401103 in b
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:12
#3  0x4010c4 in a
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:17
#4  0x4010d3 in bt
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:3
#5  0x4011d9 in main
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:3
[1]    29115 floating point exception (core dumped)  ./bt2static


So the first stack frame has some address where the corresponding symbol isn't
found. gdb doesn't find it either:

❯ gdb ./bt2static
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bt2static...done.
(gdb) r
Starting program:
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2static 

Program received signal SIGFPE, Arithmetic exception.
0x000000000040118d in c (a=0, b=0, res=2.1738888417014848e-322) at bt2.f90:7
7           res = a / b
(gdb) c
Continuing.

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic
operation.

Backtrace for this error:
#0  0x43056f in ???
#1  0x40118d in c
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:7
#2  0x401103 in b
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:12
#3  0x4010c4 in a
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:17
#4  0x4010d3 in bt
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:3
#5  0x4011d9 in main
        at
/home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/bt2.f90:3

Program received signal SIGFPE, Arithmetic exception.
0x000000000040118d in c (a=0, b=0, res=2.1738888417014848e-322) at bt2.f90:7
7           res = a / b
(gdb) bt
#0  0x000000000040118d in c (a=0, b=0, res=2.1738888417014848e-322) at
bt2.f90:7
#1  0x0000000000401104 in b () at bt2.f90:12
#2  0x00000000004010c5 in a () at bt2.f90:17
#3  0x00000000004010d4 in bt () at bt2.f90:3
#4  0x00000000004011da in main (argc=1, argv=0x7fffffffdcce) at bt2.f90:3
#5  0x000000000042a3bc in __libc_start_main ()
#6  0x0000000000400fb7 in _start ()
(gdb) info symbol 0x43056f
No symbol matches 0x43056f.


Any clue where this address comes from?

Reply via email to