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

cmd/link: crash with plugin with no exports #17681

Closed
aclements opened this issue Oct 31, 2016 · 1 comment
Closed

cmd/link: crash with plugin with no exports #17681

aclements opened this issue Oct 31, 2016 · 1 comment
Milestone

Comments

@aclements
Copy link
Member

Please answer these questions before submitting your issue. Thanks!

What did you do?

echo "package main; func init() { println("hi") }" > x.go
go build -buildmode=plugin x.go

What did you expect to see?

My very first plugin.

What did you see instead?

# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xd8 pc=0x506b24]

goroutine 1 [running]:
panic(0x5b9ea0, 0x6b3ca0)
	/home/austin/go.dev/src/runtime/panic.go:531 +0x1cf
cmd/link/internal/ld.(*deadcodepass).init(0xc420071d20)
	/home/austin/go.dev/src/cmd/link/internal/ld/deadcode.go:255 +0x744
cmd/link/internal/ld.deadcode(0xc4204a2000)
	/home/austin/go.dev/src/cmd/link/internal/ld/deadcode.go:61 +0xca
cmd/link/internal/ld.Main()
	/home/austin/go.dev/src/cmd/link/internal/ld/main.go:186 +0x820
main.main()
	/home/austin/go.dev/src/cmd/link/main.go:55 +0x139

Specifically, this seems to be because there are no exported symbols in my plugin. If I add a dummy exported symbol, the linker does not crash.

System details

go version devel +f135106 Sun Oct 30 19:14:08 2016 +0000 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/austin/r/go"
GORACE=""
GOROOT="/home/austin/go.dev"
GOTOOLDIR="/home/austin/go.dev/pkg/tool/linux_amd64"
TERM="dumb"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build901715014=/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"
uname -sr: Linux 4.2.0-42-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.5 LTS
Release:	14.04
Codename:	trusty
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu EGLIBC 2.19-0ubuntu6.9) stable release version 2.19, by Roland McGrath et al.
gdb --version: GNU gdb (GDB) 7.9-gg19
@aclements aclements added this to the Go1.8 milestone Oct 31, 2016
@gopherbot
Copy link

CL https://golang.org/cl/32437 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants