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

cmd/link : slice bounds out of range #15516

Closed
fishedee opened this issue May 3, 2016 · 4 comments
Closed

cmd/link : slice bounds out of range #15516

fishedee opened this issue May 3, 2016 · 4 comments
Milestone

Comments

@fishedee
Copy link

fishedee commented May 3, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
fish@iZ2820y71jjZ:~$ go version
go version go1.6.1 linux/amd64
  1. What operating system and processor architecture are you using (go env)?
fish@iZ2820y71jjZ:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fish/Project/fishgo"
GORACE=""
GOROOT="/home/fish/Util/go"
GOTOOLDIR="/home/fish/Util/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. 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.
//$GOPATH/src/gotest/util/util.go
package util

import (
    "github.com/go-xorm/xorm"
)


type Ctx struct{
    DB *xorm.Engine
}

type MM struct{
    Ctx
}

I write a util/util.go

//$GOPATH/src/gotest/util2/util2.go
package util2

import (
        "gotest/util"
        "github.com/go-xorm/xorm"
)

var a *xorm.Engine

type MX struct{
        util.MM
}

func Doing(){
        a := MX{}
        a.DB.NewSession()
}

I write a util2/util2.go

go install -buildmode=shared -linkshared github.com/go-xorm/xorm
go install -buildmode=shared -linkshared gotest/util
go install -buildmode=shared -linkshared gotest/util2

And cmd/link crash!!

2016/05/03 12:32:03 [build.go:62][E] build fail! error: # /tmp/go-build964506236/libmymanager-models-common.so
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x6374c0, 0xc820010100)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
cmd/link/internal/ld.decodetype_ptrdata(0xc82010f680, 0x7f17530e3000)
    /usr/local/go/src/cmd/link/internal/ld/decodesym.go:75 +0x8b
cmd/link/internal/ld.(*GCProg).AddSym(0xc822b89040, 0xc82010f7a0)
    /usr/local/go/src/cmd/link/internal/ld/data.go:1094 +0x1ec
cmd/link/internal/ld.dodata()
    /usr/local/go/src/cmd/link/internal/ld/data.go:1386 +0x1847
cmd/link/internal/ld.Ldmain()
    /usr/local/go/src/cmd/link/internal/ld/pobj.go:244 +0x1f42
cmd/link/internal/amd64.Main()
    /usr/local/go/src/cmd/link/internal/amd64/obj.go:44 +0x19
main.main()
    /usr/local/go/src/cmd/link/main.go:27 +0x36f

Crash StackTrace

  1. What did you expect to see?

NoCrash

  1. What did you see instead?

Crash

@fishedee
Copy link
Author

fishedee commented May 3, 2016

I just try again,it would also crash in go1.6.2

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone May 3, 2016
@fishedee
Copy link
Author

fishedee commented May 3, 2016

//$GOPATH/src/gotest/util2/util2.go
package util2

import (
        "gotest/util"

        //"github.com/go-xorm/xorm"
)

//remove this line
//var a *xorm.Engine

type MX struct{
        util.MM
}

func Doing(){
        a := MX{}
        a.DB.NewSession()
}

If i remove "var a *xorm.Engine"this line
it will complaint me

fish@iZ2820y71jjZ:~/Project/fishgo/pkg$ go install -buildmode=shared -linkshared gotest2/util2
# /tmp/go-build787415985/libgotest2-util2.so
gotest2/util2.Doing: github.com/go-xorm/xorm.(*Engine).NewSession: not defined
gotest2/util2.Doing: undefined: github.com/go-xorm/xorm.(*Engine).NewSession

But go install is ok,maybe shared mode can't handle nested struct import

@mwhudson mwhudson self-assigned this May 3, 2016
@mwhudson
Copy link
Contributor

mwhudson commented May 3, 2016

Thanks for the report, I'll look at this tomorrow.

@gopherbot
Copy link

CL https://golang.org/cl/22744 mentions this issue.

@golang golang locked and limited conversation to collaborators May 4, 2017
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