[英]SIGTRAP: trace trap error in Golang wrapping C library, but only when running go test
I've set up a minimal codebase repo to replicate the error and explain this error as clearly as possible: https://github.com/soroushjp/go_wrapper_c_err 我设置了一个最小的代码库存储库来复制错误并尽可能清楚地说明此错误: https : //github.com/soroushjp/go_wrapper_c_err
I'm currently working on a project doing ECDSA signing using a Go package go-secp256k1 that wraps the C secp256k1 library . 我目前正在使用Go包go-secp256k1封装EC secp256k1库的 ECDSA签名项目。
If I use the functions in go-secp256k1 directly by importing them (as seen in main.go), it works fine. 如果我通过导入直接在go-secp256k1中使用这些功能(如在main.go中看到的那样),则可以正常工作。 So in the repo, running main.go works beautifully and a public key is printed out.
因此,在回购协议中,运行main.go的工作原理非常漂亮,并且打印出了公共密钥。
So here's the strange error: If I try to write a test for a package using go-secp256k1, I receive a strange error. 因此,这是一个奇怪的错误:如果我尝试使用go-secp256k1为一个软件包编写测试 ,则会收到一个奇怪的错误。 To replicate, run:
要复制,请运行:
go test github.com/soroushjp/go_wrapper_c_err/cryptoutil -v
The error I receive: 我收到的错误:
=== RUN TestNewPublicKey
SIGTRAP: trace trap
PC=0x4031730
signal arrived during cgo execution
goroutine 20 [syscall]:
runtime.cgocall(0x40013d0, 0x436ddd0)
/usr/local/go/src/pkg/runtime/cgocall.c:143 +0xe5 fp=0x436ddb8 sp=0x436dd70
github.com/toxeus/go-secp256k1._Cfunc_secp256k1_start(0x404c14d)
github.com/toxeus/go-secp256k1/_obj/_cgo_defun.c:99 +0x31 fp=0x436ddd0 sp=0x436ddb8
github.com/toxeus/go-secp256k1.Start()
/Users/soroushjp/Desktop/Dropbox/Development/go/src/github.com/toxeus/go-secp256k1/secp256k1.go:9 +0x1a fp=0x436ddd8 sp=0x436ddd0
github.com/soroushjp/go_wrapper_c_err/cryptoutil.NewPublicKey(0xc20800e080, 0x20, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/soroushjp/go/src/github.com/soroushjp/go_wrapper_c_err/cryptoutil/cryptoutil.go:35 +0xbd fp=0x436de98 sp=0x436ddd8
github.com/soroushjp/go_wrapper_c_err/cryptoutil.TestNewPublicKey(0xc20804c090)
/Users/soroushjp/go/src/github.com/soroushjp/go_wrapper_c_err/cryptoutil/cryptoutil_test.go:10 +0x5f fp=0x436df68 sp=0x436de98
testing.tRunner(0xc20804c090, 0x420e110)
/usr/local/go/src/pkg/testing/testing.go:422 +0x8b fp=0x436df98 sp=0x436df68
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445 fp=0x436dfa0 sp=0x436df98
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:504 +0x8db
goroutine 16 [chan receive]:
testing.RunTests(0x418fe08, 0x420e110, 0x1, 0x1, 0x1)
/usr/local/go/src/pkg/testing/testing.go:505 +0x923
testing.Main(0x418fe08, 0x420e110, 0x1, 0x1, 0x4216960, 0x0, 0x0, 0x4216960, 0x0, 0x0)
/usr/local/go/src/pkg/testing/testing.go:435 +0x84
main.main()
github.com/soroushjp/go_wrapper_c_err/cryptoutil/_test/_testmain.go:47 +0x9c
goroutine 19 [finalizer wait]:
runtime.park(0x401c710, 0x4231e98, 0x4215dc9)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x4231e98, 0x4215dc9)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
goroutine 17 [syscall]:
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
rax 0x4031720
rbx 0xc208018d80
rcx 0xc208002a20
rdx 0x0
rdi 0x4403a90
rsi 0xc208002a20
rbp 0xb0103e30
rsp 0xb006efc0
r8 0x1
r9 0x3f
r10 0x3
r11 0x7fffffffffffffff
r12 0x7fff74c4e420
r13 0x1b8f53c9daf8
r14 0x4403a78
r15 0x4403a30
rip 0x4031730
rflags 0x246
cs 0x2b
fs 0x0
gs 0x0
exit status 2
FAIL github.com/soroushjp/go_wrapper_c_err/cryptoutil 0.016s
My testing code is extremely minimal and almost identical to what is going on in main.go: 我的测试代码非常少,几乎与main.go中的代码相同:
package cryptoutil
import (
"fmt"
"testing"
)
func TestNewPublicKey(t *testing.T) {
privateKey := NewPrivateKey()
publicKey, err := NewPublicKey(privateKey)
if err != nil {
t.Error(err)
}
fmt.Println(publicKey)
}
Any idea what is going on here? 知道这里发生了什么吗? What is happening different between 'go test' and 'go run' that's causing the ECDSA wrapper to run into this error?
“执行测试”和“执行”之间发生了什么不同,导致ECDSA包装器遇到此错误?
Simply updating from Go 1.4 from 1.3 solved the issue for me on OS X Mavericks. 简单地从1.3中的Go 1.4更新就可以在OS X Mavericks上解决我的问题。 The Go installer at golang.org will remove any older versions of Go when installing 1.4
golang.org上的Go安装程序将在安装1.4时删除所有较旧的Go版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.