简体   繁体   English

解释回溯错误消息

[英]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: 当我使用gfortran -g -fbacktrace -ffpe-trap = invalid,overflow,underflow File.f90编译代码时,出现以下错误:

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. 如果仅使用gfortran File.f90进行编译,则在编译或运行期间完全没有错误消息。

It might depend on which target you're using. 这可能取决于您使用的目标。 The GFortran backtrace functionality depends on libbacktrace, which might not work on all targets. GFortran回溯功能取决于libbacktrace,它可能不适用于所有目标。 On Ubuntu 16.04 x86_64 for the code 在Ubuntu 16.04 x86_64上获取代码

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. 在堆栈帧3的哪个位置,您可以看到错误发生在bt.f90的第5行。

Now, what are the stuff on stack frames #0-#2? 现在,堆栈帧#0-#2的内容是什么? Well, they are the backtracing functionality in libgfortran, the GFortran runtime library. 好吧,它们是GFortran运行时库libgfortran中的回溯功能。 libbacktrace for one reason or another cannot resolve symbols in a dynamic library. 由于某种原因,libbacktrace无法解析动态库中的符号。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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