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: load plugin crash fatal error: runtime: no plugin module data #33072

Open
WebFeng opened this issue Jul 12, 2019 · 10 comments
Open

plugin: load plugin crash fatal error: runtime: no plugin module data #33072

WebFeng opened this issue Jul 12, 2019 · 10 comments
Labels
NeedsInvestigation
Milestone

Comments

@WebFeng
Copy link

@WebFeng WebFeng commented Jul 12, 2019

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

go version go1.11.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
GOARCH="amd64"
GOBIN="/Users/webtom/go/bin"
GOCACHE="/Users/webtom/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/webtom/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0t/9w0_mgfs511g4ssg2r38cb240000gn/T/go-build339879137=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

// **notice** build plugin command:   go build -o test1.so -buildmode=plugin *.go
// **notice** test1.so and test2.so have the same content and different paths
_, err1 := plugin.Open("test1.so")
fmt.Println(err)
// err1:   plugin.Open("./test1.so"): plugin was built with a different version of package errors
_, _ = plugin.Open("test2.so")
// fatal error: runtime: no plugin module data

What did you expect to see?

No crash

What did you see instead?

fatal error: runtime: no plugin module data

goroutine 1 [running]:
runtime.throw(0x40f2177, 0x1e)
/usr/local/go/src/runtime/panic.go:608 +0x72 fp=0xc000047b00 sp=0xc000047ad0 pc=0x402a602
plugin.lastmoduleinit(0xc00008c480, 0xc00000e038, 0x4302ad0, 0x42, 0x41c7da0)
/usr/local/go/src/runtime/plugin.go:22 +0xc03 fp=0xc000047c28 sp=0xc000047b00 pc=0x402baa3
plugin.open(0x40efb00, 0x10, 0x60, 0x0, 0x0)
/usr/local/go/src/plugin/plugin_dlopen.go:87 +0x3b3 fp=0xc000047ee0 sp=0xc000047c28 pc=0x40b19d3
plugin.Open(0x40efb00, 0x13, 0x2, 0x60, 0x0)
/usr/local/go/src/plugin/plugin.go:32 +0x35 fp=0xc000047f18 sp=0xc000047ee0 pc=0x40b11e5
main.main()

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Jul 15, 2019

Thanks for the report.

You answered "Does this issue reproduce with the latest release?" with "Yes", I just want to confirm, did you test it with Go 1.12.7 or a different version?

@dmitshur dmitshur added the NeedsInvestigation label Jul 15, 2019
@dmitshur dmitshur changed the title load plugin crash fatal error: runtime: no plugin module data plugin: load plugin crash fatal error: runtime: no plugin module data Jul 15, 2019
@dmitshur dmitshur added this to the Go1.14 milestone Jul 15, 2019
@WebFeng
Copy link
Author

@WebFeng WebFeng commented Jul 16, 2019

did you test it with Go 1.12.7 or a different version?

I used Go 1.12.7 and 1.11, both versions can reproduce this problem.

@ztmr
Copy link

@ztmr ztmr commented Aug 21, 2019

I am having issue reproducible using this demo repository: https://gitlab.com/ztmr/goplugfail/-/jobs/276665302
Is this related? Is it a bug or just me doing bad things?

In my case, I think that the plugin loader treats the cshared lib's memory as C memory because it was loaded as SO from C. That would make sense but is also not really correct. Any thoughts?

@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
@spellr
Copy link

@spellr spellr commented Feb 18, 2020

This still happens in go1.13.8:

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

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Feb 18, 2020

/cc @ianlancetaylor @cherrymui per owners.

@spellr
Copy link

@spellr spellr commented Feb 18, 2020

I just found out using -buildmode=c-shared, and executing the c++ with LD_PRELOAD=./cbridge.so bypasses the problem

@spellr
Copy link

@spellr spellr commented Feb 18, 2020

If I'm not mistaken, addmoduledata is called as part of init_array, and it initializes firstmoduledata. When go is ran through a shared-object or an archive, firstmoduledata is not initialized and therefore loading the plugins fail

@rogeruiz
Copy link

@rogeruiz rogeruiz commented Nov 3, 2021

I'm seeing this happen with Golang 1.15.15, 1.16.5 and 1.17.2 as well. I'm able to successfully build the plugin, but when it comes to loading it into another Go project, I'm having the same error message about no plugin module data.

The instructions for creating a plugin I'm following are for the golangci-lint project. I am not sure if it's because of the CGO_ENABLED flag being set or not. I'm debugging that specifically separate from this issue.

I wanted to post in this Issue though because it seems related to what I'm experiencing and finding official information on this topic is not helpful. I think this issue is with the Standard Golang runtime package.

@awakchau-tibco
Copy link

@awakchau-tibco awakchau-tibco commented Mar 8, 2022

I'm seeing this happen with Golang 1.15.15, 1.16.5 and 1.17.2 as well. I'm able to successfully build the plugin, but when it comes to loading it into another Go project, I'm having the same error message about no plugin module data.

The instructions for creating a plugin I'm following are for the golangci-lint project. I am not sure if it's because of the CGO_ENABLED flag being set or not. I'm debugging that specifically separate from this issue.

I wanted to post in this Issue though because it seems related to what I'm experiencing and finding official information on this topic is not helpful. I think this issue is with the Standard Golang runtime package.

Getting the same error with golang 1.16.15, 1.17.7 and 1.17.8 when using -buildmode=plugin and GO111MODULE=off

@srilekhaMarktine
Copy link

@srilekhaMarktine srilekhaMarktine commented Mar 17, 2022

I am also facing this issue with Golang 1.13.8, with below command please kindly help to resolve..

monstache -f monstache.test.config.toml

fatal error: runtime: no plugin module data

goroutine 1 [running]:
runtime.throw({0x12709cd, 0xc0000001a0})
/usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc00021eec8 sp=0xc00021ee98 pc=0x79c191
plugin.lastmoduleinit()
/usr/local/go/src/runtime/plugin.go:20 +0x8d0 fp=0xc00021efb0 sp=0xc00021eec8 pc=0x7cb050
plugin.open({0xc000142828, 0xe})
/usr/local/go/src/plugin/plugin_dlopen.go:78 +0x3ea fp=0xc00021f220 sp=0xc00021efb0 pc=0xab406a
plugin.Open(...)
/usr/local/go/src/plugin/plugin.go:32
main.(*configOptions).loadPlugins(0xc00037e000)
/home/ubuntu/release/monstache/monstache.go:1967 +0x4e fp=0xc00021f310 sp=0xc00021f220 pc=0x106d68e
main.(*configOptions).build(0xc00037e000)
/home/ubuntu/release/monstache/monstache.go:2409 +0x5a fp=0xc00021f330 sp=0xc00021f310 pc=0x106fc3a
main.mustConfig()
/home/ubuntu/release/monstache/monstache.go:5063 +0x1b2 fp=0xc00021fec8 sp=0xc00021f330 pc=0x1083992
main.main()
/home/ubuntu/release/monstache/monstache.go:5141 +0x2b fp=0xc00021ff80 sp=0xc00021fec8 pc=0x108408b
runtime.main()
/usr/local/go/src/runtime/proc.go:255 +0x227 fp=0xc00021ffe0 sp=0xc00021ff80 pc=0x79eb27
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00021ffe8 sp=0xc00021ffe0 pc=0x7cffe1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

8 participants