After updating to macOS beta 4, go test -cover is throwing "fatal error: unexpected signal during runtime execution"

After updating to macOS beta 4, go test -cover is throwing "fatal error: unexpected signal during runtime execution"

Go build 和 go test 仍在运行。

在更新到 macOS beta 之前,我使用测试覆盖工具没有遇到任何问题。

"go test" 工作正常;但是,所有覆盖率测试命令都抛出此错误(go test -coverprofile=coverage.out 抛出相同的问题)。

如果有人知道如何解决这个问题,我将不胜感激!

$ go test -cover
go build github.com/hunteramericano/ErrorQuiver: /usr/local/Cellar/go/1.6.3/libexec/pkg/tool/darwin_amd64/cover: signal:
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x57060029ec pc=0x17cc70]

goroutine 9 [running]:
runtime.throw(0x689a00, 0x2a)
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/panic.go:547 +0x90 fp=0xc820037870 sp=0xc820037858
runtime.sigpanic()
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/sigpanic_unix.go:12 +0x5a fp=0xc8200378c0 sp=0xc820037870
sync.(*Pool).Get(0x882700, 0x0, 0x0)
/usr/local/Cellar/go/1.6.3/libexec/src/sync/pool.go:102 +0x40 fp=0xc820037910 sp=0xc8200378c0
fmt.newPrinter(0x10)
/usr/local/Cellar/go/1.6.3/libexec/src/fmt/print.go:133 +0x27 fp=0xc820037950 sp=0xc820037910
fmt.Fprintf(0xde5230, 0xc82017a150, 0x638380, 0x17, 0xc820037af0, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.6.3/libexec/src/fmt/print.go:187 +0x30 fp=0xc820037998 sp=0xc820037950
main.(*builder).runTest(0xc82017aaf0, 0xc82005e410, 0x0, 0x0)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/test.go:1070 +0x463 fp=0xc820037e00 sp=0xc820037998
main.(*builder).do.func1(0xc82005e410)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1257 +0x3b2 fp=0xc820037ec0 sp=0xc820037e00
main.(*builder).do.func2(0xc82038ae20, 0xc82017aaf0, 0xc820428400)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1314 +0x156 fp=0xc820037f98 sp=0xc820037ec0
runtime.goexit()
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820037fa0 sp=0xc820037f98
created by main.(*builder).do
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1320 +0x39e

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc82038ae2c)
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/sema.go:47 +0x26
sync.(*WaitGroup).Wait(0xc82038ae20)
/usr/local/Cellar/go/1.6.3/libexec/src/sync/waitgroup.go:127 +0xb4
main.(*builder).do(0xc82017aaf0, 0xc82005e680)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1323 +0x3c6
main.runTest(0x889620, 0xc82000a230, 0x1, 0x1)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/test.go:595 +0x2836
main.main()
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/main.go:181 +0x783

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/asm_amd64.s:1998 +0x1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
/usr/local/Cellar/go/1.6.3/libexec/src/runtime/sigqueue.go:116 +0x132
os/signal.loop()
/usr/local/Cellar/go/1.6.3/libexec/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/local/Cellar/go/1.6.3/libexec/src/os/signal/signal_unix.go:28 +0x37

goroutine 7 [select]:
main.(*builder).do.func2(0xc82038ae20, 0xc82017aaf0, 0xc820428400)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1304 +0x1cf
created by main.(*builder).do
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1320 +0x39e

goroutine 8 [select]:
main.(*builder).do.func2(0xc82038ae20, 0xc82017aaf0, 0xc820428400)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1304 +0x1cf
created by main.(*builder).do
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1320 +0x39e

goroutine 10 [select]:
main.(*builder).do.func2(0xc82038ae20, 0xc82017aaf0, 0xc820428400)
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1304 +0x1cf
created by main.(*builder).do
/usr/local/Cellar/go/1.6.3/libexec/src/cmd/go/build.go:1320 +0x39e
$

是的,go 运行时存在一些问题。我在升级到 Sierra macOS 版本后遇到了这个问题。

关于此问题的原因进行了长时间的讨论 link;

基本上,只需更改 "defer" 语句的位置即可解决此 issue.More 详细更改为 here

我通过安装 "go1.8beta2.darwin-amd64.pkg" 测试版 Go 解决了这个问题。我不再面临这个问题了。

注意:根据 this discussion,此问题未在 1.7 中修复。