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: plugin loading fails if the plugin itself imports the plugin package (even indirectly) #21969

Closed
brunoga opened this issue Sep 21, 2017 · 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

@brunoga
Copy link

brunoga commented Sep 21, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.9 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN="/home/bga/Development/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/bga/Development/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build198786462=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

I wrote down and ran the plugin example here:

https://golang.org/pkg/plugin/#Symbol

I compiled the plugin code with "go build -buildmode=plugin" then I ran the loader program with "go run".

It worked as expected:

$ go run main.go
Hello, number 7

Then I changed the plugin code from:

package main

import "fmt"

var V int

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

To:

package main

import (
  "fmt"
  _ "plugin"
)

var V int

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

Recompiled the plugin and ran the loader program again.

What did you expect to see?

$ go run main.go
Hello, number 7

What did you see instead?

$ go run main.go
panic: plugin.Open: plugin was built with a different version of package plugin

goroutine 1 [running]:
main.main()
/home/bga/Development/go/src/bga-local/plugin2/main.go:10 +0x3bb
exit status 2

@ianlancetaylor ianlancetaylor changed the title Plugin loading fails if the plugin itself imports the plugin package (even indirectly). plugin: plugin loading fails if the plugin itself imports the plugin package (even indirectly) Sep 21, 2017
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 21, 2017
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 21, 2017
@ianlancetaylor
Copy link
Contributor

CC @crawshaw

@crawshaw
Copy link
Member

I believe this is a duplicate of #21373.

The fix, https://golang.org/cl/63693, is currently marked for 1.9.1 because the underlying issue is also responsible for a -trimpath failure.

@golang golang locked and limited conversation to collaborators Sep 21, 2018
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

4 participants