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
Playing with plugin support in master, I found function calls to functions stored in structs/interfaces and returned by functions within the plugin to create a panic on darwin.
Example plugin loader:
package main
import (
"errors"
"fmt"
"os"
"plugin"
)
type testPlugin interface {
Call()
}
func main() {
for _, arg := range os.Args[1:] {
p, err := load(arg)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
p.Call()
}
}
func load(path string) (testPlugin, error) {
p, err := plugin.Open(path)
if err != nil {
return nil, err
}
sym, err := p.Lookup("Load")
if err != nil {
return nil, err
}
loader, ok := sym.(func() interface{})
if !ok {
return nil, errors.New("plugin Load-interface mismatch")
}
inst, ok := loader().(testPlugin)
if !ok {
return nil, errors.New("plugin does not implement testPlugin interface")
}
return inst, nil
}
The text was updated successfully, but these errors were encountered:
quentinmit
changed the title
Panic calling function returned by plugin function
plugin: panic calling function returned by plugin function
Nov 16, 2016
ianlancetaylor
changed the title
plugin: panic calling function returned by plugin function
plugin: panic calling function returned by plugin function on Darwin
Nov 16, 2016
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?darwin:
go version devel +d338f2e Wed Nov 16 05:51:18 2016 +0000 darwin/amd64
linux (debian 8, same commit ID as darwin):
go version master linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/urso/.gvm/pkgsets/master/global"
GORACE=""
GOROOT="/Users/urso/.gvm/gos/master"
GOTOOLDIR="/Users/urso/.gvm/gos/master/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2s/38f_b6sj0mn6_14km12vyq0r0000gn/T/go-build044211422=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
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?
Playing with plugin support in master, I found function calls to functions stored in structs/interfaces and returned by functions within the plugin to create a panic on darwin.
Example plugin loader:
Example plugin.go:
What did you expect to see?
Works on linux (debian 8).
What did you see instead?
panic in call to function being wrapped:
The text was updated successfully, but these errors were encountered: