为什么GDB会输出致命错误?

huangapple go评论80阅读模式
英文:

Why does gdb output fatal error?

问题

我正在学习使用gdb来调试Go程序。Go的版本是1.2,运行在linux/amd64上。

这个Go程序非常简单:

package main
import "fmt"
func main(){
    fmt.Printf("hello, world\n");
}

在使用gdb调试时,gdb的输出是:

$ gdb hello
GNU gdb (GDB) 7.6
版权所有 (C) 2013 Free Software Foundation, Inc.
GNU通用公共许可证第三版或更高版本 <http://gnu.org/licenses/gpl.html>
这是自由软件:您可以自由更改和重新发布它。
本软件没有任何保证,法律允许的范围内不提供任何保证。输入“show copying”和“show warranty”以获取详细信息。
此GDB配置为“x86_64-unknown-linux-gnu”。
有关错误报告说明,请参见:<http://www.gnu.org/software/gdb/bugs/>...
正在读取符号来自/data2/home/nanxiao/hello...完成。
正在加载Go运行时支持。
(gdb) start
在/data2/home/nanxiao/hello.go的第3行设置临时断点1,地址为0x400c00。
正在启动程序:/data2/home/nanxiao/hello

在/data2/home/nanxiao/hello.go的第3行,main.main ():临时断点1
3       func main(){
(gdb) n
运行时错误:pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec
致命错误:运行时错误:错误使用rewindmorestack

运行时堆栈:
runtime.throw(0x56325f)
    /data2/soft/go/src/pkg/runtime/panic.c:464 +0x69
runtime.rewindmorestack(0xc210001148)
    /data2/soft/go/src/pkg/runtime/sys_x86.c:41 +0xb4
runtime.newstack()
    /data2/soft/go/src/pkg/runtime/stack.c:230 +0x153
runtime.morestack()
    /data2/soft/go/src/pkg/runtime/asm_amd64.s:225 +0x61

根据我的理解,在运行了“n”命令之后,gdb应该执行下一条语句,并输出:

fmt.Printf("hello, world\n");

为什么会输出以下的“致命错误”?

运行时错误:pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec
致命错误:运行时错误:错误使用rewindmorestack

非常感谢您的帮助!

英文:

I am studying to use gdb to debug Go program. The Go version is 1.2, and runs on linux/amd64.

The Go program is very simple:

package main  
import &quot;fmt&quot;
func main(){
    fmt.Printf(&quot;hello, world\n&quot;);
}  

When using gdb to debug it, the gdb output is

$ gdb hello
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot; and &quot;show warranty&quot; for details.
This GDB was configured as &quot;x86_64-unknown-linux-gnu&quot;.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;...
Reading symbols from /data2/home/nanxiao/hello...done.
Loading Go Runtime support.
(gdb) start
Temporary breakpoint 1 at 0x400c00: file /data2/home/nanxiao/hello.go, line 3.
Starting program: /data2/home/nanxiao/hello

Temporary breakpoint 1, main.main () at /data2/home/nanxiao/hello.go:3
3       func main(){
(gdb) n
runtime: pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec
fatal error: runtime: misuse of rewindmorestack

runtime stack:
runtime.throw(0x56325f)
    /data2/soft/go/src/pkg/runtime/panic.c:464 +0x69
runtime.rewindmorestack(0xc210001148)
    /data2/soft/go/src/pkg/runtime/sys_x86.c:41 +0xb4
runtime.newstack()
    /data2/soft/go/src/pkg/runtime/stack.c:230 +0x153
runtime.morestack()
    /data2/soft/go/src/pkg/runtime/asm_amd64.s:225 +0x61  

Per my understanding, after running the "n" command, the gdb should go the next statement, and the output is:

fmt.Printf(&quot;hello, world\n&quot;);  

Why does it output the following "fatal error"?

runtime: pc=0x400c13 0xcc 0xeb 0x48 0x83 0xec
fatal error: runtime: misuse of rewindmorestack  

Thanks very much in advance!

答案1

得分: 3

这是版本1.2的问题。在版本1.2.1中已经修复了,你可以从以下链接下载:https://code.google.com/p/go/downloads/list

英文:

It was an issue with version 1.2. It's fixed in version 1.2.1, you can download it from: https://code.google.com/p/go/downloads/list

huangapple
  • 本文由 发表于 2014年1月24日 11:03:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/21323654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定