du0173 2013-05-31 01:09
浏览 68
已采纳

如何解释堆栈跟踪中的负行号

I made some changes to a fairly large project of mine today, and now I'm getting some odd behavior. Because I'm a knucklehead, I can't go back and figure out what I did.

But the main thrust of my question is how I should understand the negative line number in the stack trace that is printed. The -1218 below is the one that I mean.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x80501f2]

goroutine 1 [running]:
server.init()              //     vv-------------RIGHT HERE
    /home/.../debugComponent.go:-1218 +0x282
_/home/.../possessions.init()
    /home/.../possessions.go:29 +0x42
_/home/.../pageWrap.init()
    /home/.../pageWrap.go:112 +0x47

main.init()
    /home/.../main.go:0 +0x3c

goroutine 2 [syscall]:

goroutine 3 [runnable]:

The associated debugComponent.go file is pretty non-essential right now, so I removed it to see what would happen, and the file name just gets replaced with a different one, and a different negative number.

I've had to find plenty of bugs while developing this app, but this one has got me stumped.


If it helps, there's the main.go and then several packages in play. The three files listed above are all different packages, and this seems to be happening during the imports.


I hope you've read this far, because here's the strangest part. If I add this declaration to main.go, the error goes away!

var test = func() int { return 1 }() // Everything is fine now!

Very confusing! It doesn't fix it if I do var test = "foobar". It has to be the invoked func.


Any insight is appreciated, but mostly I'm curious about the -1218 in the trace.


Update

I'm trying to get this down to a small example that reproduces the issue. After working on it I reverted back to my original code, and restarted the machine.

The first time I tried to build and run, two new entries were added to the top of the stack trace. But only the first time.

goroutine 1 [syscall]:
syscall.Syscall()
    /usr/local/go/src/pkg/syscall/asm_linux_386.s:14 +0x5
syscall.Mkdir(0x83a2f18, 0x2, 0x2, 0x806255e, 0x83a2f1c, ...)
    /usr/local/go/src/pkg/syscall/zerrors_linux_386.go:2225 +0x80
server.init()

So this would be in line with my main question about interpreting stack trace. The -1218 is still there, but now there are these.

The asm_linux_386.s has this at line 14:

MOVL    4(SP), AX       // syscall entry

I found the zerrors_linux_386.go too, but there's no line 2225. The file stops long before that line.

  • 写回答

2条回答 默认 最新

  • douwen5246 2013-07-10 09:51
    关注

    It's already reported and accepted as Issue 5243.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?