-
Notifications
You must be signed in to change notification settings - Fork 18k
plugin, runtime: goroutines in go plugins can't access channels #24351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm getting what appears to be the same crash with a simpler plugin: plugin.go
main.go
In fact, replacing the argument to
Stack trace (for runtime stack: goroutine 19 [copystack]: goroutine 1 [select (no cases)]: goroutine 2 [force gc (idle)]: goroutine 3 [GC sweep wait]: goroutine 18 [finalizer wait]: runtime stack: |
/cc @aclements |
I cannot reproduce either of these errors on Linux/amd64. |
@randall77 I think this might be related to #24257 and #23369 |
Also confirming the same crash. 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64 go version go1.10 darwin/amd64 |
I was able to reproduce on my mac. |
Probably a dup of #23133, let's move the discussion over there. |
Change https://golang.org/cl/100739 mentions this issue: |
When there are plugins, there may not be a unique copy of runtime functions like goexit, mcall, etc. So identifying them by entry address is problematic. Instead, keep track of each special function using a field in the symbol table. That way, multiple copies of the same runtime function will be treated identically. Fixes #24351 Fixes #23133 Change-Id: Iea3232df8a6af68509769d9ca618f530cc0f84fd Reviewed-on: https://go-review.googlesource.com/100739 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/102793 mentions this issue: |
…nstead of address When there are plugins, there may not be a unique copy of runtime functions like goexit, mcall, etc. So identifying them by entry address is problematic. Instead, keep track of each special function using a field in the symbol table. That way, multiple copies of the same runtime function will be treated identically. Fixes #24351 Fixes #23133 Change-Id: Iea3232df8a6af68509769d9ca618f530cc0f84fd Reviewed-on: https://go-review.googlesource.com/100739 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-on: https://go-review.googlesource.com/102793 Run-TryBot: Andrew Bonventre <andybons@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
I'm running into something similar to this. Version: |
It seems like you cant pass channels to a go routine started in a go plugin. The same thing works fine with an int, but not with a chan.
Am I missing something ?
What version of Go are you using (
go version
)?go version go1.10 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nila/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/nila/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pf/r881yf9x7y98jk_0g_fvlm6w0000gn/T/go-build571346567=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
var channel = make(chan string) log.Println(channel) go func(ch chan string) { log.Println(ch) }(channel)
Working code in main (or any other function called from main)
https://play.golang.org/p/ZrbWS1ZiNR6
Non-working code:
Exactly the same one, but executed in a go plugin
What did you expect to see?
The memory address of the channel printed out twice
2018/03/11 21:03:05 0xc420082180 2018/03/11 21:03:05 0xc420082180
What did you see instead?
The memory address and a crashdump
2018/03/11 21:03:44 Loading Plugin TestPlugin v1.0...
2018/03/11 21:03:44 0xc4200901e0
2018/03/11 21:03:44 Loaded Plugin TestPlugin
runtime: unexpected return pc for runtime.goexit called from 0xc4200901e0
stack: frame={sp:0xc420044fd8, fp:0xc420044fe0} stack=[0xc420044000,0xc420045000)
000000c420044ed8: 0000000000000000 0000000004469fc0
000000c420044ee8: 00000000042a48c0 000000c420032fb8
000000c420044ef8: 000000c420044f50 00000000052bc772 <fmt.Sprintln+82>
000000c420044f08: 000000c42011a000 000000c420044fb8
000000c420044f18: 0000000000000001 0000000000000001
000000c420044f28: 0000000000000000 0000000000000000
000000c420044f38: 0000000000000000 0000000000000000
000000c420044f48: 000000c42011a000 000000c420044f90
000000c420044f58: 00000000052c619f <log.Println+63> 000000c420032fb8
000000c420044f68: 0000000000000001 0000000000000001
000000c420044f78: 0000000000000000 0000000000000000
000000c420044f88: 0000000000000000 000000c420032fc8
000000c420044f98: 00000000052c664b <plugin/unnamed-caabc8dcf500ae927b9ba74909699f191add99b3.(*TestPlugin).OnLoad.func1+91> 000000c420032fb8
000000c420044fa8: 0000000000000001 0000000000000001
000000c420044fb8: 00000000052dc4a0 000000c4200901e0
000000c420044fc8: 0000000000000000 0000000005266ab1 <runtime.goexit+1>
000000c420044fd8: <000000c4200901e0 >0000000000000000
000000c420044fe8: 0000000000000000 0000000000000000
000000c420044ff8: 0000000000000000
fatal error: unknown caller pc
runtime stack:
runtime: unexpected return pc for runtime.morestack called from 0x0
stack: frame={sp:0x70000d85de80, fp:0x70000d85de88} stack=[0x70000d7de290,0x70000d85de90)
000070000d85dd80: 000000c420076180 000070000d85ddd0
000070000d85dd90: 0000000004016e5c <runtime.(*mcentral).grow+236> 000000c41fff72ff
000070000d85dda0: 000000c400000000 0000000004597e50
000070000d85ddb0: 0000000004597e50 000000000000002a
000070000d85ddc0: 000000c420084780 000000c420032b38
000070000d85ddd0: 00000000052ba42b <fmt.(*fmt).fmt_integer+475> 000000c420084780
000070000d85dde0: 0000000000000000 0000000000000000
000070000d85ddf0: 0000000000000000 0000000000000000
000070000d85de00: 0000000000002000 0000000004597e50
000070000d85de10: 000000c420000100 000070000d85de48
000070000d85de20: 000000000401652c <runtime.(*mcache).refill+156> 000000000448f610
000070000d85de30: 0000000004597e50 000000000000001a
000070000d85de40: 000000c420076180 000070000d85de68
000070000d85de50: 00000000040522e2 <runtime.(*mcache).nextFree.func1+50> 0000000004592458
000070000d85de60: 000000c42007611a 000000c420032d98
000070000d85de70: 000000c420032b78 0000000005264659 <runtime.morestack+137>
000070000d85de80: <0000000000000000 >0100000004600000
runtime.throw(0x53035c6, 0x11)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:619 +0x81
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420084780, 0x0, 0x0, 0x7fffffff, 0x5308d10, 0x70000d85dbc0, 0x0, ...)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:302 +0x1c48
runtime.copystack(0xc420084780, 0x1000, 0x70000d85dd01)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:891 +0x26e
runtime.newstack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:1063 +0x310
runtime: unexpected return pc for runtime.morestack called from 0x0
stack: frame={sp:0x70000d85de80, fp:0x70000d85de88} stack=[0x70000d7de290,0x70000d85de90)
000070000d85dd80: 000000c420076180 000070000d85ddd0
000070000d85dd90: 0000000004016e5c <runtime.(*mcentral).grow+236> 000000c41fff72ff
000070000d85dda0: 000000c400000000 0000000004597e50
000070000d85ddb0: 0000000004597e50 000000000000002a
000070000d85ddc0: 000000c420084780 000000c420032b38
000070000d85ddd0: 00000000052ba42b <fmt.(*fmt).fmt_integer+475> 000000c420084780
000070000d85dde0: 0000000000000000 0000000000000000
000070000d85ddf0: 0000000000000000 0000000000000000
000070000d85de00: 0000000000002000 0000000004597e50
000070000d85de10: 000000c420000100 000070000d85de48
000070000d85de20: 000000000401652c <runtime.(*mcache).refill+156> 000000000448f610
000070000d85de30: 0000000004597e50 000000000000001a
000070000d85de40: 000000c420076180 000070000d85de68
000070000d85de50: 00000000040522e2 <runtime.(*mcache).nextFree.func1+50> 0000000004592458
000070000d85de60: 000000c42007611a 000000c420032d98
000070000d85de70: 000000c420032b78 0000000005264659 <runtime.morestack+137>
000070000d85de80: <0000000000000000 >0100000004600000
runtime.morestack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:480 +0x89
The text was updated successfully, but these errors were encountered: