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: random "unexpected fault address 0x0" error on invoking an exported function #19824

Closed
vimalk78 opened this issue Apr 3, 2017 · 3 comments

Comments

@vimalk78
Copy link

vimalk78 commented Apr 3, 2017

Please answer these questions before submitting your issue. Thanks!

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

$ go version
go version go1.8 linux/amd64

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/vimal/gowork"
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-build007409990=/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?

created a plugin with go build -buildmode=plugin

opened the plugin a go program with plugin.Open
searched for a exported function with plugin.Loopup and invoked it

    s, err := p.Lookup(PLUGIN_METHOD_INIT_NAME)
    if err != nil {
        dlog.Error("find symbol failed")
        return err
    }
    if s == nil {
        dlog.Error("find symbol failed, found nil symbol")
        return fmt.Errorf("found nil symbol")
    }

    initf, ok := s.(func(engine.PluginInit) error)
    if !ok {
        dlog.Error("load plugin failed")
        return fmt.Errorf("function type mismatch")
    }
    initf(engine.PluginInit{          // << it carshes here
        CreateLoggerFunc: func(logp string) api.Logger {
            return log.GetLogger(logp)
        }})

What did you expect to see?

plugin loaded successfully

What did you see instead?

$ ./engine
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x1053ca0]

goroutine 1 [running]:
runtime.throw(0x15a89bf, 0x5)
        /usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc42032b6f8 sp=0xc42032b6d8
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:297 +0x28c fp=0xc42032b748 sp=0xc42032b6f8
mypackage.(*PluginManager).OpenPlugin(0xc42043e620, 0xc42028e280, 0xc420011128, 0x5)

this happens randomly.

prior to this i got error "plugin was built with a different version of xyz package" and plugin failed to load, then i rebuilt the plugin and getting this error.

i should mention that there are another 3 plugins which are being loaded in the same manner.

@vimalk78 vimalk78 changed the title plugin: "unexpected fault address 0x0" error on invoking an exported function plugin: random "unexpected fault address 0x0" error on invoking an exported function Apr 3, 2017
@ianlancetaylor
Copy link
Contributor

CC @crawshaw

@tzneal
Copy link
Member

tzneal commented Apr 11, 2017

Dupe of #19269

@tzneal
Copy link
Member

tzneal commented Apr 17, 2017

Dupe, verified fixed in tip.

@tzneal tzneal closed this as completed Apr 17, 2017
@golang golang locked and limited conversation to collaborators Apr 17, 2018
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

4 participants