如何调试 Revel 构建崩溃日志?

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

how to debug revel build crash log?

问题

我想将我的应用程序投入生产,但在尝试执行revel build app时,我遇到了一个错误日志,我很难理解。

以下是日志的一部分:

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

goroutine 1 [running]:
main.func·002()
	/home/johnny/data/go/src/github.com/revel/cmd/revel/rev.go:71 +0x7e
main.func·003(0xc208a4a400, 0x1001, 0x0, 0x0, 0x7ff4863a9238, 0xc2081ee420, 0x0, 0x0)
	/home/johnny/data/go/src/github.com/revel/cmd/revel/util.go:96 +0x2b5
path/filepath.walk(0xc208617000, 0xff1, 0x7ff4863a9260, 0xc20883cff0, 0xc2085799c8, 0x0, 0x0)
	/usr/lib/go/src/path/filepath/path.go:368 +0x430

日志中的其他行始终指向/usr/lib/go/src/path/filepath/path.go

日志的末尾是:

goroutine 5 [syscall]:
os/signal.loop()
	/usr/lib/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
	/usr/lib/go/src/os/signal/signal_unix.go:27 +0x35

这个日志让我想起了Objective-C,我知道调试它是多么困难。

也许我在路由中漏掉了一些东西?我在.gitignore中有一些文件(我不确定这是否与崩溃有关?)

英文:

I want to put my app in production but I am having trouble understanding this error log that I am getting while trying to do revel build app

This is part of log:

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

goroutine 1 [running]:
main.func·002()
	/home/johnny/data/go/src/github.com/revel/cmd/revel/rev.go:71 +0x7e
main.func·003(0xc208a4a400, 0x1001, 0x0, 0x0, 0x7ff4863a9238, 0xc2081ee420, 0x0, 0x0)
	/home/johnny/data/go/src/github.com/revel/cmd/revel/util.go:96 +0x2b5
path/filepath.walk(0xc208617000, 0xff1, 0x7ff4863a9260, 0xc20883cff0, 0xc2085799c8, 0x0, 0x0)
	/usr/lib/go/src/path/filepath/path.go:368 +0x430

Other lines in log always reffer to this /usr/lib/go/src/path/filepath/path.go

and at the end of log is this:

goroutine 5 [syscall]:
os/signal.loop()
	/usr/lib/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
	/usr/lib/go/src/os/signal/signal_unix.go:27 +0x35

This log reminds me of objective C and I know how is hard to debug that.

Maybe I am missing something in routes somewhere? I have some files in .gitignore (i am not sure if that has to do something with a crash?)

答案1

得分: 1

你可能需要熟悉Go的堆栈跟踪。这里有一个不错的教程:http://www.goinggo.net/2015/01/stack-traces-in-go.html

基本上,你需要在堆栈跟踪中寻找处于"[running]"状态的goroutine(通常在堆栈跟踪的最顶部),并找出触发panic的那一行代码。

在这个例子中,github.com/revel/cmd/revel/util.go:96看起来是这样的:

        if info.IsDir() {
			err := os.MkdirAll(path.Join(destDir, relSrcPath), 0777)
			if !os.IsExist(err) {
				panicOnError(err, "Failed to create directory")
			}
			return nil
		}

Panic报告的是panic: runtime error: invalid memory address or nil pointer dereference,所以很可能是infonil(你也可以在调用path/filepath.Walk时看到它的值为0x0)。

看起来像是revel的一个bug,没有完整的代码和环境信息,无法确定。

英文:

You probably need to get familiar with Go stack traces. Here is nice tutorial: http://www.goinggo.net/2015/01/stack-traces-in-go.html

Basically, you have to look for the goroutine in the [running] state (it usually on the very top of the stack trace) and find out line, which triggered panic.

In this example, github.com/revel/cmd/revel/util.go:96 looks like this:

        if info.IsDir() {
			err := os.MkdirAll(path.Join(destDir, relSrcPath), 0777)
			if !os.IsExist(err) {
				panicOnError(err, "Failed to create directory")
			}
			return nil
		}

Panic says panic: runtime error: invalid memory address or nil pointer dereference, so it must be info to be nil (you can see it also as 0x0 in the call to path/filepath.Walk.

Looks like revel bug, not sure without full code/env information.

huangapple
  • 本文由 发表于 2015年8月30日 22:28:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/32297598.html
匿名

发表评论

匿名网友

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

确定