dsfbnhc4373 2017-05-01 22:19
浏览 45

在Go程序中获取C代码堆栈跟踪

I'm using the rana/ora oracle driver in my Go program to query some Oracle tables.

The program somehow always gets SIGSEGV from a C library after running for a while and exits on segfault. It also gets a lot of query timeouts (context deadline exceeded) before it hits segfault error.

I'm using the driver in a pretty standard way:

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Seconds)
defer cancel()
rows, err := initialedDb.QueryContext(ctx, "sql_query")

The stack trace from the 1st Goroutine is:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x7fbb03e5d193]
runtime stack:
runtime.throw(0xa4a0a4, 0x2a)
    /usr/local/go/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:274 +0x2db
goroutine 5230 [syscall, locked to thread]:
runtime.cgocall(0x921850, 0xc421667348, 0xa495f1)
    /usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc421667308 sp=0xc4216672c8
gopkg.in/rana/ora%2ev4._Cfunc_OCIAttrGet(0x2c92f08, 0x35, 0xc421cb8be4, 0xc421cb8be8, 0x5, 0x2b81930, 0xc400000000)
    gopkg.in/rana/ora.v4/_obj/_cgo_gotypes.go:347 +0x4d fp=0xc421667348 sp=0xc421667308
gopkg.in/rana/ora%2ev4.(*Rset).paramAttr.func1(0x2c92f08, 0xc400000035, 0xc421cb8be4, 0xc421cb8be8, 0x5, 0x2b81930, 0xf1ef01)
    /go/src/gopkg.in/rana/ora.v4/rset.go:970 +0xfc fp=0xc421667390 sp=0xc421667348
gopkg.in/rana/ora%2ev4.(*Rset).paramAttr(0xc4211f22d0, 0x2c92f08, 0xc421cb8be4, 0xc421cb8be8, 0xc400000005, 0x0, 0x0)
    /go/src/gopkg.in/rana/ora.v4/rset.go:976 +0x88 fp=0xc4216673e0 sp=0xc421667390
gopkg.in/rana/ora%2ev4.(*Rset).open(0xc4211f22d0, 0xc421358000, 0x7fbae405ed28, 0x0, 0x0)
    /go/src/gopkg.in/rana/ora.v4/rset.go:554 +0xd43 fp=0xc421667b98 sp=0xc4216673e0
gopkg.in/rana/ora%2ev4.(*Stmt).qryC(0xc421358000, 0xf1e940, 0xc421ace900, 0xc421cb8ad0, 0x1, 0x1, 0xc4211f22d0, 0x0, 0x0)
    /go/src/gopkg.in/rana/ora.v4/stmt.go:442 +0x3e0 fp=0xc421667f18 sp=0xc421667b98
gopkg.in/rana/ora%2ev4.(*DrvStmt).QueryContext.func1(0xc421b73260, 0xc420e789e8, 0xc420e789e0, 0xf1e940, 0xc421ace900, 0xc421cb8ad0, 0x1, 0x1)
    /go/src/gopkg.in/rana/ora.v4/drvStmt_go1_8.go:76 +0xa6 fp=0xc421667fa0 sp=0xc421667f18
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc421667fa8 sp=0xc421667fa0
created by gopkg.in/rana/ora%2ev4.(*DrvStmt).QueryContext
    /go/src/gopkg.in/rana/ora.v4/drvStmt_go1_8.go:82 +0x30c

I checked my program many times and I don't think I'm causing any memory leaks, double frees or anything like that.

I wonder how I can debug this since Go doesn't give me C's stack trace. Will Valgrind's Memcheck tool help?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题