golang不知道大家是否熟悉?今天我将给大家介绍《运行时:从0x0调用的runtime.Gopark意外返回pc》,这篇文章主要会讲到等等知识点,如果你在看完本篇文章后,有更好的建议或者发现哪里有
golang不知道大家是否熟悉?今天我将给大家介绍《运行时:从0x0调用的runtime.Gopark意外返回pc》,这篇文章主要会讲到等等知识点,如果你在看完本篇文章后,有更好的建议或者发现哪里有问题,希望大家都能积极评论指出,谢谢!希望我们能一起加油进步!
我写了一个go项目,用于包装对etcd的访问,并提供接口给C语言使用,https://GitHub.com/dingrui37/etcdagent,(对不起我英文不好)
完成该项目的测试后,我将其构建为共享库:
go build -buildmode=c-shared -o cgo/libetcd.so main.go
但是运行时有时会出现如下异常,有人可以帮我吗?
[newthread0x7fff9a7fc700(lwp1615)]
runtime:unexpectedreturnpcforruntime.goparkcalledfrom0x0
stack:frame={sp:0xc000062f90,fp:0xc000062fb0}stack=[0xc000062800,0xc000063000)
000000c000062e90:00000000000000000000000000000000
000000c000062ea0:00000000000000000000000000000000
000000c000062eb0:00000000000000000000000000000000
000000c000062ec0:00000000000000000000000000000000
000000c000062ed0:00000000000000000000000000000000
000000c000062ee0:00000000000000000000000000000000
000000c000062ef0:00000000000000000000000000000000
000000c000062f00:00000000000000000000000000000000
000000c000062f10:00000000000000000000000000000000
000000c000062f20:00000000000000000000000000000000
000000c000062f30:00000000000000000000000000000000
000000c000062f40:00000000000000000000000000000000
000000c000062f50:00000000000000000000000000000000
000000c000062f60:00000000000000000000000000000000
000000c000062f70:00000000000000000000000000000000
000000c000062f80:00000000000000000000000000000000
000000c000062f90:<00000000000000000000000000000000
000000c000062fa0:0000000000000000!0000000000000000
000000c000062fb0:>00000000000000000000000000000000
000000c000062fc0:00000000000000000000000000000000
000000c000062fd0:0000000000000000000000000106e371<runtime.goexit+1>
000000c000062fe0:00000000000000000000000000000000
000000c000062ff0:00000000000000000000000000000000
fatalerror:unknowncallerpc
runtimestack:
runtime.throw(0x1d15977,0x11)
/usr/local/go/src/runtime/panic.go:774+0x74
runtime.gentraceback(0xffffffffffffffff,0xffffffffffffffff,0x0,0xc000000a80,0x0,
0x0,0x7fffffff,0x7fff9affb3c8,0x0,0x0,...)
/usr/local/go/src/runtime/traceback.go:273+0x19e9
runtime.scanstack(0xc000000a80,0xc000043270)
/usr/local/go/src/runtime/mGCmark.go:711+0x161
runtime.scang(0xc000000a80,0xc000043270)
/usr/local/go/src/runtime/proc.go:886+0x1e5
runtime.markroot.func1()
/usr/local/go/src/runtime/mgcmark.go:221+0x71
runtime.markroot(0xc000043270,0xc000000007)
/usr/local/go/src/runtime/mgcmark.go:202+0x2f5
runtime.gcdrain(0xc000043270,0x2)
/usr/local/go/src/runtime/mgcmark.go:915+0x114
runtime.gcbgmarkworker.func2()
/usr/local/go/src/runtime/mgc.go:1923+0x122
runtime.systemstack(0x0)
/usr/local/go/src/runtime/asm_amd64.s:370+0x63
runtime.mstart()
/usr/local/go/src/runtime/proc.go:1146
goroutine220[gcworker(idle)]:
runtime.systemstack_switch()
/usr/local/go/src/runtime/asm_amd64.s:330fp=0xc00033f760sp=0xc00033f758
pc=0x106c270
runtime.gcbgmarkworker(0xc000042000)
/usr/local/go/src/runtime/mgc.go:1891+0x1c5fp=0xc00033f7d8
sp=0xc00033f760pc=0x102ee15
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1357+0x1fp=0xc00033f7e0
sp=0xc00033f7d8pc=0x106e371
createdbyruntime.gcbgmarkstartworkers
/usr/local/go/src/runtime/mgc.go:1785+0x79
goroutine4[syscall]:
os/signal.signal_recv(0x0)
/usr/local/go/src/runtime/sigqueue.go:147+0x9e
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:23+0x24
createdbyos/signal.init.0
/usr/local/go/src/os/signal/signal_unix.go:29+0x43
goroutine36[select]:
google.golang.org/grpc.(*ccbalancerwrapper).watcher(0xc000176280)
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/balancer_conn_wrappers.go:
115+0x12e
createdbygoogle.golang.org/grpc.newccbalancerwrapper
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/balancer_conn_wrappers.go:
106+0x16b
goroutine44[select]:
google.golang.org/grpc/internal/transport.(*controlbuffer).get(0xc000168230,0x1,
0x0,0x0,0x0,0x0)
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/internal/transport/control
buf.go:395+0x124
google.golang.org/grpc/internal/transport.(*loopywriter).run(0xc000174c00,0x0,
0x0)
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/internal/transport/control
buf.go:513+0x1e5
google.golang.org/grpc/internal/transport.newHttp2client.func3(0xc00026e000)
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/internal/transport/http2_c
lient.go:338+0x7d
createdbygoogle.golang.org/grpc/internal/transport.newhttp2client
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/internal/transport/http2_c
lient.go:336+0xebe
goroutine38[chanreceive]:
etcdagent/agent.(*agent).run(0xc000176380)
/home/dingrui/projects/etcdagent/agent/agent.go:75+0x14e
createdbymain.etcdagentinit.func1
/home/dingrui/projects/etcdagent/main.go:62+0x203
goroutine39[select]:
etcdagent/agent/event.(*event).watch(0xc0001720a0,0x248e520,0xc000176400,
0xc000174600)
/home/dingrui/projects/etcdagent/agent/event/event.go:45+0x408
createdbyetcdagent/agent.(*agent).run
/home/dingrui/projects/etcdagent/agent/agent.go:72+0x124
goroutine20[chanreceive]:
google.golang.org/grpc.(*addrconn).resettransport(0xc00023c000)
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:1077
+0x6ae
createdbygoogle.golang.org/grpc.(*addrconn).connect
/home/dingrui/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:743
+0x122
goroutine43[iowait]:
internal/poll.runtime_pollwait(0x7ffff7f48dd8,0x72,0xffffffffffffffff)
/usr/local/go/src/runtime/netpoll.go:184+0x57
internal/poll.(*polldesc).wait(0xc00024e198,0x72,0x8000,0x8000,
0xffffffffffffffff)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:87+0x47
internal/poll.(*polldesc).waitread(...)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*fd).read(0xc00024e180,0xc000256000,0x8000,0x8000,0x0,0x0,0x0)
/usr/local/go/src/internal/poll/fd_unix.go:169+0x1d1
net.(*netfd).read(0xc00024e180,0xc000256000,0x8000,0x8000,0x0,0x800010601,0x0)
/usr/local/go/src/net/fd_unix.go:202+0x51
net.(*conn).read(0xc0001720c8,0xc000256000,0x8000,0x8000,0x0,0x0,0x0)
/usr/local/go/src/net/net.go:184+0x6a
dingrui@dingrui-PC:~$ go version
go version go1.13.1 linux/amd64
dingrui@dingrui-PC:~$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dingrui/.cache/go-build"
GOENV="/home/dingrui/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dingrui/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build180008548=/tmp/go-build -gno-record-gcc-switches"
我会非常仔细地阅读 go 文档中关于 signal
的这一部分
https://pkg.go.dev/os/signal#hdr-Go_programs_that_use_cgo_or_SWIG
特别是这个声明
大概您正在使用 cgo 集成到该 c 库中。如果 c 代码安装了信号处理程序,您可能会遇到此问题。
为了解决这个问题,您可能需要编写一个小的 c 函数,并在 go 代码进行任何系统调用之前调用它。它将 sa_onstack 标志添加到信号处理程序中,可能如下所示:
void set_signal_sa_onstack() {
struct sigaction action;
struct sigaction old_action;
sigaction(SIGCHLD, NULL, &action);
action.sa_flags = action.sa_flags | SA_ONSTACK;
sigaction(SIGCHLD, &action, &old_action);
}
好了,本文到此结束,带大家了解了《运行时:从0x0调用的runtime.gopark意外返回pc》,希望本文对你有所帮助!关注编程网公众号,给大家分享更多Golang知识!
--结束END--
本文标题: 运行时:从0x0调用的runtime.gopark意外返回pc
本文链接: https://lsjlt.com/news/596029.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-05
2024-04-05
2024-04-05
2024-04-04
2024-04-05
2024-04-05
2024-04-05
2024-04-05
2024-04-04
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0