Skip to content
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

plugin, runtime: goroutines in go plugins can't access channels #24351

Closed
Waffeldrache opened this issue Mar 11, 2018 · 10 comments
Closed

plugin, runtime: goroutines in go plugins can't access channels #24351

Waffeldrache opened this issue Mar 11, 2018 · 10 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Waffeldrache
Copy link

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

@dpinela
Copy link
Contributor

dpinela commented Mar 11, 2018

I'm getting what appears to be the same crash with a simpler plugin:

plugin.go

package main

import (
	"fmt"
)

func B() {
	go fmt.Println(1.5)
	select {}
}

main.go

package main

import (
	"plugin"
)

func main() {
	p, err := plugin.Open("pluginchan.so")
	if err != nil {
		panic(err)
	}
	f, err := p.Lookup("B")
	if err != nil {
		panic(err)
	}
	f.(func())()
}

In fact, replacing the argument to Println with any value other than an integer, a string, a byte slice, an empty/nil slice or an empty struct still crashes, the only difference being which print routines show up on the stack trace.

go env output:
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dpinela/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dpinela/dev/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/41/2xpv_r1j5n5bnflwb7s1hv580000gp/T/go-build316125966=/tmp/go-build -gno-record-gcc-switches -fno-common"

Stack trace (for fmt.Println(1.5)):
runtime: bad pointer in frame strconv.genericFtoa at 0xc420040c60: 0x20
fatal error: invalid pointer found on stack

runtime stack:
runtime.throw(0x45e7083, 0x1e)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:619 +0x81 fp=0x7ffeefbff310 sp=0x7ffeefbff2f0 pc=0x45279b1
runtime.adjustpointers(0xc420040c48, 0x7ffeefbff408, 0x7ffeefbff7d8, 0x462ee38, 0x465ea40)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:592 +0x23e fp=0x7ffeefbff380 sp=0x7ffeefbff310 pc=0x453b41e
runtime.adjustframe(0x7ffeefbff6e8, 0x7ffeefbff7d8, 0x465ea40)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:663 +0x32c fp=0x7ffeefbff438 sp=0x7ffeefbff380 pc=0x453b76c
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420066780, 0x0, 0x0, 0x7fffffff, 0x45ea1f0, 0x7ffeefbff7d8, 0x0, ...)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:355 +0x136c fp=0x7ffeefbff750 sp=0x7ffeefbff438 pc=0x45444cc
runtime.copystack(0xc420066780, 0x1000, 0x7ffeefbff901)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:891 +0x26e fp=0x7ffeefbff908 sp=0x7ffeefbff750 pc=0x453c25e
runtime.newstack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:1063 +0x310 fp=0x7ffeefbffa98 sp=0x7ffeefbff908 pc=0x453c670
runtime: unexpected return pc for runtime.morestack called from 0x0
stack: frame={sp:0x7ffeefbffa98, fp:0x7ffeefbffaa0} stack=[0x7ffeefb80640,0x7ffeefbffac0)
00007ffeefbff998: 00000000040bb020 00007ffeefbff9e8
00007ffeefbff9a8: 00000000045135cc <runtime.(*mcentral).grow+236> 000000c41fffa0ff
00007ffeefbff9b8: 000000c400000000 0000000004118ee0
00007ffeefbff9c8: 0000000004118ee0 000000000000002a
00007ffeefbff9d8: 000000c420066780 000000c42002eb00
00007ffeefbff9e8: 0000000004555107 <strconv.genericFtoa+1511> 000000c420066780
00007ffeefbff9f8: 0000000000000000 0000000000000000
00007ffeefbffa08: 0000000000000000 0000000000000000
00007ffeefbffa18: 0000000000002000 0000000004118ee0
00007ffeefbffa28: 00000000040bb001 00007ffeefbffa60
00007ffeefbffa38: 0000000004512c4c <runtime.(*mcache).refill+156> 00000000040c1230
00007ffeefbffa48: 0000000004118ee0 000000000000001a
00007ffeefbffa58: 00000000040bb020 00007ffeefbffa80
00007ffeefbffa68: 0000000004547bc2 <runtime.(*mcache).nextFree.func1+50> 00000000041136c8
00007ffeefbffa78: 00000000040bb01a 000000c42002ed88
00007ffeefbffa88: 000000c42002ec88 000000000454a459 <runtime.morestack+137>
00007ffeefbffa98: <0000000000000000 >00007ffeefbffaf8
00007ffeefbffaa8: 000000000404b023 <runtime.rt0_go+515> 00007ffeefbffaf8
00007ffeefbffab8: 000000000404b02a <runtime.rt0_go+522>
runtime.morestack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:480 +0x89 fp=0x7ffeefbffaa0 sp=0x7ffeefbffa98 pc=0x454a459

goroutine 19 [copystack]:
strconv.(*extFloat).ShortestDecimal(0xc420040c08, 0xc420040c58, 0xc420040bc0, 0xc420040ba8, 0x4659dd0)
/usr/local/Cellar/go/1.10/libexec/src/strconv/extfloat.go:532 +0x4fe fp=0xc420040b00 sp=0xc420040af8 pc=0x455495e
strconv.genericFtoa(0xc4200be068, 0x1, 0x44, 0x3ff8000000000000, 0x67, 0xffffffffffffffff, 0x40, 0x4118e48, 0x0, 0xc42002ed80)
/usr/local/Cellar/go/1.10/libexec/src/strconv/ftoa.go:115 +0x5e7 fp=0xc420040c98 sp=0xc420040b00 pc=0x4555107
strconv.AppendFloat(0xc4200be068, 0x1, 0x44, 0x3ff8000000000000, 0x67, 0xffffffffffffffff, 0x40, 0xc42002ed88, 0x450e866, 0x4118ee0)
/usr/local/Cellar/go/1.10/libexec/src/strconv/ftoa.go:51 +0x75 fp=0xc420040cf8 sp=0xc420040c98 pc=0x4554ae5
fmt.(*fmt).fmt_float(0xc4200be040, 0x3ff8000000000000, 0x40, 0x67, 0xffffffffffffffff)
/usr/local/Cellar/go/1.10/libexec/src/fmt/format.go:459 +0x9c fp=0xc420040dd8 sp=0xc420040cf8 pc=0x45a101c
fmt.(*pp).fmtFloat(0xc4200be000, 0x3ff8000000000000, 0x40, 0xc400000076)
/usr/local/Cellar/go/1.10/libexec/src/fmt/print.go:398 +0x170 fp=0xc420040e10 sp=0xc420040dd8 pc=0x45a3430
fmt.(*pp).printArg(0xc4200be000, 0x4063580, 0x45f60e0, 0x76)
/usr/local/Cellar/go/1.10/libexec/src/fmt/print.go:643 +0x1f4 fp=0xc420040e88 sp=0xc420040e10 pc=0x45a51a4
fmt.(*pp).doPrintln(0xc4200be000, 0xc420086200, 0x1, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/fmt/print.go:1146 +0x45 fp=0xc420040ef8 sp=0xc420040e88 pc=0x45a8175
fmt.Fprintln(0x45f6d20, 0xc420092eb8, 0xc420086200, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.10/libexec/src/fmt/print.go:254 +0x58 fp=0xc420040f60 sp=0xc420040ef8 pc=0x45a2248
fmt.Println(0xc420086200, 0x1, 0x1, 0xc4200a6368, 0xc4200a6360, 0x0)
/usr/local/Cellar/go/1.10/libexec/src/fmt/print.go:264 +0x5a fp=0xc420040fb0 sp=0xc420040f60 pc=0x45a234a
runtime: unexpected return pc for runtime.goexit called from 0xc420086200
stack: frame={sp:0xc420040fb0, fp:0xc420040fb8} stack=[0xc420040000,0xc420041000)
000000c420040eb0: 000000c4200bc080 000000c4200bc0a8
000000c420040ec0: 000000c42002eee8 0000000000000000
000000c420040ed0: 0000000004666d50 00000000045dbfe0
000000c420040ee0: 000000c420086200 000000c42002ef50
000000c420040ef0: 00000000045a2248 <fmt.Fprintln+88> 000000c4200be000
000000c420040f00: 000000c420086200 0000000000000001
000000c420040f10: 0000000000000001 0000000000000000
000000c420040f20: 0000000000000000 0000000000000000
000000c420040f30: 0000000000000000 000000c4200be000
000000c420040f40: 0000000000000000 0000000000000000
000000c420040f50: 000000c42002efa0 00000000045a234a <fmt.Println+90>
000000c420040f60: 00000000045f6d20 000000c420092eb8
000000c420040f70: 000000c420086200 0000000000000001
000000c420040f80: 0000000000000001 0000000000000000
000000c420040f90: 0000000000000000 0000000000000000
000000c420040fa0: 0000000000000000 000000000454c8b1 <runtime.goexit+1>
000000c420040fb0: <000000c420086200 >0000000000000001
000000c420040fc0: 0000000000000001 000000c4200a6368
000000c420040fd0: 000000c4200a6360 0000000000000000
000000c420040fe0: 0000000000000000 0000000000000000
000000c420040ff0: 0000000000000000 0000000000000000
runtime.goexit()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420040fb8 sp=0xc420040fb0 pc=0x454c8b1
created by plugin/unnamed-78a5ff0a5c3e9b286722d6c9bac9e1919e7f521c.B
/Users/dpinela/dev/go/src/pluginchan/pluginchan.go:8 +0xa0

goroutine 1 [select (no cases)]:
runtime.gopark(0x0, 0x0, 0x45e4b5a, 0x11, 0x10, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:291 +0x126 fp=0xc420055e78 sp=0xc420055e58 pc=0x4529346
runtime.block()
/usr/local/Cellar/go/1.10/libexec/src/runtime/select.go:192 +0x4c fp=0xc420055eb8 sp=0xc420055e78 pc=0x4535fdc
plugin/unnamed-78a5ff0a5c3e9b286722d6c9bac9e1919e7f521c.B()
/Users/dpinela/dev/go/src/pluginchan/pluginchan.go:9 +0xa5 fp=0xc420055f08 sp=0xc420055eb8 pc=0x45a8685
main.main()
/Users/dpinela/dev/go/src/pluginchan/main.go:16 +0xb7 fp=0xc420055f88 sp=0xc420055f08 pc=0x4056697
runtime.main()
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:198 +0x212 fp=0xc420055fe0 sp=0xc420055f88 pc=0x4029262
runtime.goexit()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420055fe8 sp=0xc420055fe0 pc=0x404d721

goroutine 2 [force gc (idle)]:
runtime.gopark(0x407cd70, 0x40bacb0, 0x4078945, 0xf, 0x407cc14, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:291 +0x11a fp=0xc420032768 sp=0xc420032748 pc=0x40296aa
runtime.goparkunlock(0x40bacb0, 0x4078945, 0xf, 0x14, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:297 +0x5e fp=0xc4200327a8 sp=0xc420032768 pc=0x402975e
runtime.forcegchelper()
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:248 +0xcc fp=0xc4200327e0 sp=0xc4200327a8 pc=0x40294ec
runtime.goexit()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc4200327e8 sp=0xc4200327e0 pc=0x404d721
created by runtime.init.4
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:237 +0x35

goroutine 3 [GC sweep wait]:
runtime.gopark(0x407cd70, 0x40bada0, 0x4078635, 0xd, 0x401d014, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:291 +0x11a fp=0xc420032f60 sp=0xc420032f40 pc=0x40296aa
runtime.goparkunlock(0x40bada0, 0x4078635, 0xd, 0x14, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:297 +0x5e fp=0xc420032fa0 sp=0xc420032f60 pc=0x402975e
runtime.bgsweep(0xc420064000)
/usr/local/Cellar/go/1.10/libexec/src/runtime/mgcsweep.go:52 +0xa3 fp=0xc420032fd8 sp=0xc420032fa0 pc=0x401d113
runtime.goexit()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420032fe0 sp=0xc420032fd8 pc=0x404d721
created by runtime.gcenable
/usr/local/Cellar/go/1.10/libexec/src/runtime/mgc.go:216 +0x58

goroutine 18 [finalizer wait]:
runtime.gopark(0x45ea3f8, 0x40d6f58, 0x45e4371, 0xe, 0x14, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:291 +0x126 fp=0xc42002e718 sp=0xc42002e6f8 pc=0x4529346
runtime.goparkunlock(0x40d6f58, 0x45e4371, 0xe, 0x14, 0x1)
/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:297 +0x5e fp=0xc42002e758 sp=0xc42002e718 pc=0x45293fe
runtime.runfinq()
/usr/local/Cellar/go/1.10/libexec/src/runtime/mfinal.go:175 +0xbe fp=0xc42002e7e0 sp=0xc42002e758 pc=0x4513d3e
fatal error: unexpected signal during runtime execution
panic during panic
[signal SIGSEGV: segmentation violation code=0x1 addr=0x119 pc=0x45446d3]

runtime stack:
runtime.startpanic_m()
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:693 +0x179 fp=0x7ffeefbfec78 sp=0x7ffeefbfec50 pc=0x4026f59
runtime.startpanic()
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:592 +0x1e fp=0x7ffeefbfec90 sp=0x7ffeefbfec78 pc=0x4026b3e
runtime.throw(0x407bf7f, 0x2a)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:618 +0x74 fp=0x7ffeefbfecb0 sp=0x7ffeefbfec90 pc=0x4026c64
runtime.sigpanic()
/usr/local/Cellar/go/1.10/libexec/src/runtime/signal_unix.go:372 +0x28e fp=0x7ffeefbfed00 sp=0x7ffeefbfecb0 pc=0x40399be
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420066600, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, ...)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:290 +0x1573 fp=0x7ffeefbff018 sp=0x7ffeefbfed00 pc=0x45446d3
runtime.traceback1(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420066600, 0x0)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:729 +0xfd fp=0x7ffeefbff180 sp=0x7ffeefbff018 pc=0x454564d
runtime.traceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420066600)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:690 +0x52 fp=0x7ffeefbff1b8 sp=0x7ffeefbff180 pc=0x45454c2
runtime.tracebackothers(0x40bb020)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:879 +0x1b7 fp=0x7ffeefbff220 sp=0x7ffeefbff1b8 pc=0x4546027
runtime.dopanic_m(0x40bb020, 0x45279b1, 0x7ffeefbff2f0)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:739 +0x2d1 fp=0x7ffeefbff290 sp=0x7ffeefbff220 pc=0x4527fd1
runtime.dopanic.func1()
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:601 +0x3c fp=0x7ffeefbff2b8 sp=0x7ffeefbff290 pc=0x454943c
runtime.dopanic(0x0)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:600 +0x4a fp=0x7ffeefbff2f0 sp=0x7ffeefbff2b8 pc=0x45278da
runtime.throw(0x45e7083, 0x1e)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:619 +0x81 fp=0x7ffeefbff310 sp=0x7ffeefbff2f0 pc=0x45279b1
runtime.adjustpointers(0xc420040c48, 0x7ffeefbff408, 0x7ffeefbff7d8, 0x462ee38, 0x465ea40)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:592 +0x23e fp=0x7ffeefbff380 sp=0x7ffeefbff310 pc=0x453b41e
runtime.adjustframe(0x7ffeefbff6e8, 0x7ffeefbff7d8, 0x465ea40)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:663 +0x32c fp=0x7ffeefbff438 sp=0x7ffeefbff380 pc=0x453b76c
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc420066780, 0x0, 0x0, 0x7fffffff, 0x45ea1f0, 0x7ffeefbff7d8, 0x0, ...)
/usr/local/Cellar/go/1.10/libexec/src/runtime/traceback.go:355 +0x136c fp=0x7ffeefbff750 sp=0x7ffeefbff438 pc=0x45444cc
runtime.copystack(0xc420066780, 0x1000, 0x7ffeefbff901)
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:891 +0x26e fp=0x7ffeefbff908 sp=0x7ffeefbff750 pc=0x453c25e
runtime.newstack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/stack.go:1063 +0x310 fp=0x7ffeefbffa98 sp=0x7ffeefbff908 pc=0x453c670
runtime: unexpected return pc for runtime.morestack called from 0x0
stack: frame={sp:0x7ffeefbffa98, fp:0x7ffeefbffaa0} stack=[0x7ffeefb80640,0x7ffeefbffac0)
00007ffeefbff998: 00000000040bb020 00007ffeefbff9e8
00007ffeefbff9a8: 00000000045135cc <runtime.(*mcentral).grow+236> 000000c41fffa0ff
00007ffeefbff9b8: 000000c400000000 0000000004118ee0
00007ffeefbff9c8: 0000000004118ee0 000000000000002a
00007ffeefbff9d8: 000000c420066780 000000c42002eb00
00007ffeefbff9e8: 0000000004555107 <strconv.genericFtoa+1511> 000000c420066780
00007ffeefbff9f8: 0000000000000000 0000000000000000
00007ffeefbffa08: 0000000000000000 0000000000000000
00007ffeefbffa18: 0000000000002000 0000000004118ee0
00007ffeefbffa28: 00000000040bb001 00007ffeefbffa60
00007ffeefbffa38: 0000000004512c4c <runtime.(*mcache).refill+156> 00000000040c1230
00007ffeefbffa48: 0000000004118ee0 000000000000001a
00007ffeefbffa58: 00000000040bb020 00007ffeefbffa80
00007ffeefbffa68: 0000000004547bc2 <runtime.(*mcache).nextFree.func1+50> 00000000041136c8
00007ffeefbffa78: 00000000040bb01a 000000c42002ed88
00007ffeefbffa88: 000000c42002ec88 000000000454a459 <runtime.morestack+137>
00007ffeefbffa98: <0000000000000000 >00007ffeefbffaf8
00007ffeefbffaa8: 000000000404b023 <runtime.rt0_go+515> 00007ffeefbffaf8
00007ffeefbffab8: 000000000404b02a <runtime.rt0_go+522>
runtime.morestack()
/usr/local/Cellar/go/1.10/libexec/src/runtime/asm_amd64.s:480 +0x89 fp=0x7ffeefbffaa0 sp=0x7ffeefbffa98 pc=0x454a459

@andybons andybons changed the title Go routines in go plugins can't access channels runtime/plugin: goroutines in go plugins can't access channels Mar 12, 2018
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 12, 2018
@andybons andybons added this to the Go1.11 milestone Mar 12, 2018
@andybons
Copy link
Member

/cc @aclements

@randall77
Copy link
Contributor

I cannot reproduce either of these errors on Linux/amd64.
I'll try on a Mac when I get home.

@Waffeldrache
Copy link
Author

@randall77 I think this might be related to #24257 and #23369

@RayfenWindspear
Copy link

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

@randall77
Copy link
Contributor

I was able to reproduce on my mac.
The crash happens when copying the stack. It looks like it fails to trigger the top of stack termination condition and walks off the end of the stack.
I haven't yet determined why it does that. The obvious answer is that goexitPC is somehow different in the plugin. But that would only be a problem if the plugin came with its own runtime package. I don't think we do that.
I also don't understand why this would happen on a mac but not on linux.
More investigation to do.

@randall77
Copy link
Contributor

Probably a dup of #23133, let's move the discussion over there.

@gopherbot
Copy link

Change https://golang.org/cl/100739 mentions this issue: runtime: identify special functions by flag instead of address

gopherbot pushed a commit that referenced this issue Mar 15, 2018
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>
@dmitshur dmitshur changed the title runtime/plugin: goroutines in go plugins can't access channels plugin, runtime: goroutines in go plugins can't access channels Mar 20, 2018
@gopherbot
Copy link

Change https://golang.org/cl/102793 mentions this issue: [release-branch.go1.10] runtime: identify special functions by flag instead of address

gopherbot pushed a commit that referenced this issue Mar 29, 2018
…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>
@umitanuki
Copy link

I'm running into something similar to this. Version: go version go1.10.2 darwin/amd64
When the panic appears, the plugin is allocating a new key and assign int constant to a map inside a closure function, and this map is created outside of the closure. Not sure if that is the trigger condition or not. This code has been running without problem in Linux since 1.9.

@golang golang locked and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants