You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I compile a Go plugin without importing "C" I can compile it but when plugin.Open() is called on it, the application crashes with "fatal error: invalid runtime symbol table"
What version of Go are you using (go version)?
go version go1.8rc1 linux/amd64
What operating system and processor architecture are you using (go env)?
The text was updated successfully, but these errors were encountered:
ianlewis
changed the title
Go 1.8rc1 not importing "C" in plugin produces unintuitive error at runtime
Go 1.8rc1 not importing "C" in plugin produces unintuitive panic at runtime
Jan 13, 2017
josharian
changed the title
Go 1.8rc1 not importing "C" in plugin produces unintuitive panic at runtime
plugin: import "C" in plugin produces unintuitive panic
Jan 13, 2017
ianlewis
changed the title
plugin: import "C" in plugin produces unintuitive panic
plugin: failing to import "C" in plugin produces unintuitive runtime panic
Jan 13, 2017
Ah yes, this kept slipping my mind. I think it should be straightforward to add a runtime/cgo dependency for plugins in cmd/go. Let me give it a try...
It looks like cmd/go already has logic for adding a runtime/cgo dependency to all plugins, cmd/go/pkg.go:937. The error you are seeing here is the same one Keith ran into in CL 35116. It was fixed yesterday in CL 35190. Your example succeeds when built against HEAD.
If I compile a Go plugin without importing "C" I can compile it but when plugin.Open() is called on it, the application crashes with "fatal error: invalid runtime symbol table"
What version of Go are you using (
go version
)?go version go1.8rc1 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/ianlewis/opt/go-workspace"
GORACE=""
GOROOT="/usr/local/google/home/ianlewis/opt/go1.8rc1.linux-amd64"
GOTOOLDIR="/usr/local/google/home/ianlewis/opt/go1.8rc1.linux-amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build476586089=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
main.go
plugin.go
I compile the plugin:
go build -buildmode=plugin -o plugin_name.so plugin.go
and run the program:
go run main.go
What did you expect to see?
I expect a more useful error message at plugin compile time.
What did you see instead?
The application then crashes with the following traceback.
The text was updated successfully, but these errors were encountered: