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: opening plugin built with -linkshared flag results in stackoverflow #19852

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

Comments

@vimalk78
Copy link

vimalk78 commented Apr 5, 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-build731397511=/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?

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

executable program :

package main

import (
    "fmt"
    "os"
    "plugin"
    "runtime/debug"
)

func main() {
    debug.SetMaxStack(100)
    pn := os.Args[1]
    _, err := plugin.Open(pn)
    if err != nil {
        fmt.Printf("go to hell %s", err)
        return
    }
}

exe built with :
go build -v -a

plugin :

package main

import (
    "C"
    "io/ioutil"

    yaml "gopkg.in/yaml.v2"
)

func TEST(file string) error {
    b, err := ioutil.ReadFile(file)
    if err != nil {
        panic(err)
    }
    var testObj interface{}
    err = yaml.Unmarshal(b, &testObj)
    if err != nil {
        panic(err)
    }
    return nil
}

plugin built with :
go build -v -a -buildmode=plugin -linkshared

What did you expect to see?

plugin loaded, and executed

What did you see instead?

stackoverflow error

runtime: goroutine stack exceeds 100-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x533ed6, 0xe)
    /usr/local/go/src/runtime/panic.go:596 +0x95
runtime.newstack(0x0)
    /usr/local/go/src/runtime/stack.go:1089 +0x3f2
runtime.morestack()
    /usr/local/go/src/runtime/asm_amd64.s:398 +0x86

goroutine 1 [running]:
runtime.(*_type).nameOff(0x7fd5cbe4b720, 0x1ae50, 0x0)
    /usr/local/go/src/runtime/type.go:198 +0x4c fp=0xc42004e358 sp=0xc42004e350
runtime.(*_type).string(0x7fd5cbe4b720, 0x0, 0x0)
    /usr/local/go/src/runtime/type.go:46 +0x36 fp=0xc42004e380 sp=0xc42004e358
runtime.typesEqual(0x7fd5cbe4b720, 0x513e20, 0x50c2d7)
    /usr/local/go/src/runtime/type.go:543 +0x73 fp=0xc42004e4a8 sp=0xc42004e380
runtime.typesEqual(0x7fd5cbe55580, 0x5196c0, 0x0)
    /usr/local/go/src/runtime/type.go:580 +0x229 fp=0xc42004e5d0 sp=0xc42004e4a8
runtime.typesEqual(0x7fd5cbe5be20, 0x51ece0, 0x5099df)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004e6f8 sp=0xc42004e5d0
runtime.typesEqual(0x7fd5cbe45aa0, 0x50ecc0, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004e820 sp=0xc42004e6f8
runtime.typesEqual(0x7fd5cbe6b820, 0x52ab80, 0x50556b)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004e948 sp=0xc42004e820
runtime.typesEqual(0x7fd5cbe6e3c0, 0x52d480, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004ea70 sp=0xc42004e948
runtime.typesEqual(0x7fd5cbe5c500, 0x51eb00, 0x50556b)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004eb98 sp=0xc42004ea70
runtime.typesEqual(0x7fd5cbe6e120, 0x52d1e0, 0x50aa98)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004ecc0 sp=0xc42004eb98
runtime.typesEqual(0x7fd5cbe52340, 0x518480, 0x0)
    /usr/local/go/src/runtime/type.go:567 +0x951 fp=0xc42004ede8 sp=0xc42004ecc0
runtime.typesEqual(0x7fd5cbe62380, 0x523080, 0x50c5b7)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004ef10 sp=0xc42004ede8
runtime.typesEqual(0x7fd5cbe46a20, 0x50e300, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004f038 sp=0xc42004ef10
runtime.typesEqual(0x7fd5cbe62380, 0x523080, 0x50c5b7)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004f160 sp=0xc42004f038
runtime.typesEqual(0x7fd5cbe46a20, 0x50e300, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004f288 sp=0xc42004f160
runtime.typesEqual(0x7fd5cbe62380, 0x523080, 0x50c5b7)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004f3b0 sp=0xc42004f288
runtime.typesEqual(0x7fd5cbe46a20, 0x50e300, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004f4d8 sp=0xc42004f3b0
runtime.typesEqual(0x7fd5cbe62380, 0x523080, 0x50c5b7)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004f600 sp=0xc42004f4d8
runtime.typesEqual(0x7fd5cbe46a20, 0x50e300, 0x0)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004f728 sp=0xc42004f600
runtime.typesEqual(0x7fd5cbe62380, 0x523080, 0x50c5b7)
    /usr/local/go/src/runtime/type.go:647 +0xc0a fp=0xc42004f850 sp=0xc42004f728
runtime.typesEqual(0x7fd5cbe46a20, 0x50e300, 0xc4bd46f0ff)
    /usr/local/go/src/runtime/type.go:627 +0x9c5 fp=0xc42004f978 sp=0xc42004f850
runtime.typelinksinit()
    /usr/local/go/src/runtime/type.go:510 +0x432 fp=0xc42004fb80 sp=0xc42004f978
plugin.lastmoduleinit(0x2574400, 0xc42000e028, 0x25754c0, 0x72, 0x7b7f60)
    /usr/local/go/src/runtime/plugin.go:52 +0x2f9 fp=0xc42004fcb0 sp=0xc42004fb80
plugin.open(0x7fff73cffca2, 0x39, 0x0, 0x0, 0x0)
    /usr/local/go/src/plugin/plugin_dlopen.go:72 +0x25d fp=0xc42004fef0 sp=0xc42004fcb0
plugin.Open(0x7fff73cffca2, 0x39, 0x5016a5, 0x0, 0x0)
    /usr/local/go/src/plugin/plugin.go:30 +0x35 fp=0xc42004ff28 sp=0xc42004fef0
main.main()
    /home/vimal/gowork/src/rnd-isourceb.huawei.com/v70420/tests/plugininvoker/main.go:13 +0x5c fp=0xc42004ff88 sp=0xc42004ff28
runtime.main()
    /usr/local/go/src/runtime/proc.go:185 +0x20a fp=0xc42004ffe0 sp=0xc42004ff88
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42004ffe8 sp=0xc42004ffe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

I have limited the stack size to be able to print the beginning of stack.

otherwise the error is:
runtime: goroutine stack exceeds 1000000000-byte limit

@ianlancetaylor
Copy link
Contributor

CC @crawshaw @mwhudson

@vimalk78
Copy link
Author

vimalk78 commented Apr 5, 2017

possible duplicate of #19258

@tzneal
Copy link
Member

tzneal commented Apr 17, 2017

Duplicate, 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