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: Open with cgo panics: runtime: no plugin module data #37286

Closed
spellr opened this issue Feb 18, 2020 · 2 comments
Closed

plugin: Open with cgo panics: runtime: no plugin module data #37286

spellr opened this issue Feb 18, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@spellr
Copy link

spellr commented Feb 18, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.8 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/speller/.cache/go-build"
GOENV="/home/speller/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/speller/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/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-build530246739=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Using cgo, I run go code from my C++ code, and the go code loads a plugin.
This results in a panic.

cbridge.go:

package main

import (
	"C"
	"fmt"
	"plugin"
)

func main() {
	LoadPlugin("/tmp/plugin.so")
}

//export LoadPlugin
func LoadPlugin(path string) {
    fmt.Println("In cbridge.go ", path)
    _, _ = plugin.Open(path)
}

plugin.go:

package main

import "fmt"

func main() {
	fmt.Println("In plugin!")
}

In my c++ code:

std::string plugin("/tmp/plugin.so");
LoadPlugin(GoString{plugin.c_str(), static_cast<ptrdiff_t>(plugin.size())});

Running cbridge.go directly works, so it's code is fine.
Running it through the C++ code using cgo results in this crash:

In cbridge.go /tmp/plugin.so
fatal error: runtime: no plugin module data

goroutine 17 [running, locked to thread]:
runtime.throw(0x55df236ade9b, 0x1e)
	GOROOT/src/runtime/panic.go:774 +0x74 fp=0xc0000548e0 sp=0xc0000548b0 pc=0x55df20e5ab24
plugin.lastmoduleinit(0xc00009ac00, 0x1001, 0x1001, 0xc0000b2020, 0x55df27259e00)
	GOROOT/src/runtime/plugin.go:20 +0xb31 fp=0xc000054a00 sp=0xc0000548e0 pc=0x55df20e5bef1
plugin.open(0x7f480257e950, 0xb, 0x5e4c0a83, 0x28a2b168, 0x1c0bf56d57c1)
	GOROOT/src/plugin/plugin_dlopen.go:77 +0x517 fp=0xc000054c90 sp=0xc000054a00 pc=0x55df210d8847
plugin.Open(0x7f480257e950, 0xe, 0x55df25aaaee0, 0xf, 0x0)
	GOROOT/src/plugin/plugin.go:32 +0x37 fp=0xc000054cc8 sp=0xc000054c90 pc=0x55df210d7f57
main.LoadPlugin(0x7f480257e950, 0xe)
	cbridge.go:17 +0x125 fp=0xc000054e20 sp=0xc000054cc8 pc=0x55df210d9995
main._cgoexpwrap_181dbf39f508_LoadPlugin(0x7f480257e950, 0xe)
	_cgo_gotypes.go:51 +0x37 fp=0xc000054e40 sp=0xc000054e20 pc=0x55df210d9777
runtime.call32(0x0, 0x7f480257e840, 0x7f480257e900, 0x10)
	src/runtime/asm_amd64.s:539 +0x3d fp=0xc000054e70 sp=0xc000054e40 pc=0x55df20e8628d
runtime.cgocallbackg1(0x0)
	GOROOT/src/runtime/cgocall.go:314 +0x1bb fp=0xc000054f58 sp=0xc000054e70 pc=0x55df20e3036b
runtime.cgocallbackg(0x0)
	GOROOT/src/runtime/cgocall.go:191 +0xc7 fp=0xc000054fc0 sp=0xc000054f58 pc=0x55df20e30117
runtime.cgocallback_gofunc(0x0, 0x0, 0x0, 0x0)
	src/runtime/asm_amd64.s:793 +0x9a fp=0xc000054fe0 sp=0xc000054fc0 pc=0x55df20e8789a
runtime.goexit()
	src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000054fe8 sp=0xc000054fe0 pc=0x55df20e87ff1
@toothrot toothrot changed the title plugin.Open with cgo panics plugin: Open with cgo panics Feb 18, 2020
@toothrot toothrot added this to the Backlog milestone Feb 18, 2020
@toothrot toothrot changed the title plugin: Open with cgo panics plugin: Open with cgo panics: runtime: no plugin module data Feb 18, 2020
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 18, 2020
@toothrot
Copy link
Contributor

/cc @ianlancetaylor @cherrymui

@spellr This could be a duplicate of #33072

@spellr
Copy link
Author

spellr commented Feb 18, 2020

@toothrot seems like it is.
I'll close, thanks

@spellr spellr closed this as completed Feb 18, 2020
@golang golang locked and limited conversation to collaborators Feb 17, 2021
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

3 participants