简体   繁体   中英

interpreting backtrace error message

When I compile my code using gfortran -g -fbacktrace -ffpe-trap=invalid,overflow,underflow File.f90 I get the following error:

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

Backtrace for this error:

#0 0x7f3da0768ed7 in ???
#1 0x7f3da076810d in ???
#2 0x7f3d9fe9b7ef in ???
#3 0x7f3da0230a3e in ???

My question is: how can I interpret these numbers and ???'s under "backtrace for this error:". How can I use this error message to help me find the error? Are they somehow related to the specific lines of code that are problematic? If so, how?

As of now I realize I have an erroneous arithmetic operation error but I have no idea where and this backtrace error message doesn't help at all. If I compile using just gfortran File.f90, there are no error messages at all during compilation or during running.

It might depend on which target you're using. The GFortran backtrace functionality depends on libbacktrace, which might not work on all targets. On Ubuntu 16.04 x86_64 for the code

program bt
  use iso_fortran_env
  implicit none
  real(real64) :: a, b = -1
  a = sqrt(b)
  print *, a
end program bt

when compiling with

gfortran -g -ffpe-trap=invalid  bt.f90

I get

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

Backtrace for this error:
#0  0x7F08C38E8E08
#1  0x7F08C38E7F90
#2  0x7F08C35384AF
#3  0x4007F9 in MAIN__ at bt.f90:5
zsh: floating point exception  ./a.out

where on stack frame #3 you can see that the error occurs on line 5 in bt.f90.

Now, what are the stuff on stack frames #0-#2? Well, they are the backtracing functionality in libgfortran, the GFortran runtime library. libbacktrace for one reason or another cannot resolve symbols in a dynamic library. If I link it statically:

gfortran -g -static -ffpe-trap=invalid  bt.f90

I get

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

Backtrace for this error:
#0  0x40139E in _gfortrani_backtrace
#1  0x400D00 in _gfortrani_backtrace_handler
#2  0x439B2F in gsignal
#3  0x400C01 in MAIN__ at bt.f90:5
zsh: floating point exception  ./a.out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM