golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.93k stars 17.66k forks source link

plugin #17195

Closed xoba closed 8 years ago

xoba commented 8 years ago

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.

add function F2 to src/test/test.go — the standard plugin example https://tip.golang.org/pkg/plugin/#Symbol

package main

// // No C code needed.
import "C"

import "fmt"

var V int

func F2(i *int) {
}

func F() {
    fmt.Printf("Hello, number %d\n", V)
}

then build as go build -buildmode=plugin test

What did you expect to see?

file test.so in cwd.

What did you see instead?

# test
panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x59e760, 0x68e520)
    /root/go/src/runtime/panic.go:496 +0x1a0
cmd/link/internal/ld.(*deadcodepass).flood(0xc420519ce8)
    /root/go/src/cmd/link/internal/ld/deadcode.go:289 +0xdea
cmd/link/internal/ld.deadcode(0xc4204ba000)
    /root/go/src/cmd/link/internal/ld/deadcode.go:60 +0xdb
cmd/link/internal/ld.Main()
    /root/go/src/cmd/link/internal/ld/main.go:185 +0x805
main.main()
    /root/go/src/cmd/link/main.go:55 +0x139

Does this issue reproduce with the latest release (go1.7.1)?

n/a

System details

go version devel +dcbbd31 Thu Sep 22 06:41:11 2016 +0000 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GOROOT="/home/mra/go"
GOTOOLDIR="/home/mra/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build514935108=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
uname -sr: Linux 3.13.0-37-generic
Distributor ID: LinuxMint
Description:    Linux Mint 17.1 Rebecca
Release:    17.1
Codename:   rebecca
/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 (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
crawshaw commented 8 years ago

I believe this is a duplicate of #17140. (Which I intend to fix soon, I've just almost got this all working on darwin/amd64 and want to get that out first.)