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

go/types: crash in unsafe.Offsetof #16902

Closed
BenLubar opened this issue Aug 27, 2016 · 5 comments
Closed

go/types: crash in unsafe.Offsetof #16902

BenLubar opened this issue Aug 27, 2016 · 5 comments
Assignees
Milestone

Comments

@BenLubar
Copy link

@BenLubar BenLubar commented Aug 27, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +0d23c28 Sat Aug 27 00:08:36 2016 +0000 linux/amd64

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

    GOARCH="amd64"
    GOBIN="/home/ben/go/bin"
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/home/ben/.golang-path:/home/ben/.golang-bootstrap/path:/home/ben/go"
    GORACE=""
    GOROOT="/home/ben/.golang"
    GOTOOLDIR="/home/ben/.golang/pkg/tool/linux_amd64"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build819085466=/tmp/go-build -gno-record-gcc-switches"
    CXX="g++"
    CGO_ENABLED="1"
    
  3. What did you do?

    ben@australium:~/go/src/hello$ go get -u golang.org/x/tools/cmd/ssadump
    ben@australium:~/go/src/hello$ which ssadump
    /home/ben/go/bin/ssadump
    ben@australium:~/go/src/hello$ ls
    hello.go
    ben@australium:~/go/src/hello$ cat hello.go 
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("hello world")
    }
    ben@australium:~/go/src/hello$ ssadump -build F .
    panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range
    
    goroutine 84 [running]:
    panic(0x692180, 0xc4200100b0)
        /home/ben/.golang/src/runtime/panic.go:500 +0x1a0
    go/types.(*Checker).handleBailout(0xc42024e620, 0xc420d77dd0)
        /home/ben/.golang/src/go/types/check.go:213 +0xae
    panic(0x692180, 0xc4200100b0)
        /home/ben/.golang/src/runtime/panic.go:458 +0x241
    go/types.(*Config).offsetof(0xc42027ec40, 0x7fd4c0, 0xc4217ca660, 0xc421593030, 0x1, 0x1, 0xc421619e00)
        /home/ben/.golang/src/go/types/sizes.go:194 +0x105
    go/types.(*Checker).builtin(0xc42024e620, 0xc42159cc00, 0xc42040e400, 0x10, 0xc42159ca00)
        /home/ben/.golang/src/go/types/builtins.go:567 +0x44e9
    go/types.(*Checker).call(0xc42024e620, 0xc42159cc00, 0xc42040e400, 0x3)
        /home/ben/.golang/src/go/types/call.go:44 +0x6ae
    go/types.(*Checker).exprInternal(0xc42024e620, 0xc42159cc00, 0x7fde80, 0xc42040e400, 0x0, 0x0, 0x0)
        /home/ben/.golang/src/go/types/expr.go:1369 +0x2063
    go/types.(*Checker).rawExpr(0xc42024e620, 0xc42159cc00, 0x7fde80, 0xc42040e400, 0x0, 0x0, 0x0)
        /home/ben/.golang/src/go/types/expr.go:945 +0x8d
    go/types.(*Checker).multiExpr(0xc42024e620, 0xc42159cc00, 0x7fde80, 0xc42040e400)
        /home/ben/.golang/src/go/types/expr.go:1475 +0x62
    go/types.(*Checker).expr(0xc42024e620, 0xc42159cc00, 0x7fde80, 0xc42040e400)
        /home/ben/.golang/src/go/types/expr.go:1469 +0x49
    go/types.(*Checker).constDecl(0xc42024e620, 0xc4212de360, 0x0, 0x0, 0x7fde80, 0xc42040e400)
        /home/ben/.golang/src/go/types/decl.go:124 +0x21f
    go/types.(*Checker).objDecl(0xc42024e620, 0x801d00, 0xc4212de360, 0x0, 0xc420d77d18, 0x0, 0x8)
        /home/ben/.golang/src/go/types/decl.go:78 +0x30f
    go/types.(*Checker).packageObjects(0xc42024e620, 0xc4207d4000, 0x879, 0xa00)
        /home/ben/.golang/src/go/types/resolver.go:423 +0x12c
    go/types.(*Checker).checkFiles(0xc42024e620, 0xc420072000, 0x58, 0x58, 0x0, 0x0)
        /home/ben/.golang/src/go/types/check.go:227 +0xe4
    go/types.(*Checker).Files(0xc42024e620, 0xc420072000, 0x58, 0x58, 0x1d, 0xc420477770)
        /home/ben/.golang/src/go/types/check.go:218 +0x49
    golang.org/x/tools/go/loader.(*importer).addFiles(0xc420056480, 0xc42024a4d0, 0xc420072000, 0x58, 0x58, 0x1)
        /home/ben/.golang-path/src/golang.org/x/tools/go/loader/loader.go:1009 +0x123
    golang.org/x/tools/go/loader.(*importer).load(0xc420056480, 0xc4202afc00, 0xc42000a740)
        /home/ben/.golang-path/src/golang.org/x/tools/go/loader/loader.go:975 +0x16c
    golang.org/x/tools/go/loader.(*importer).startLoad.func1(0xc420056480, 0xc4202afc00, 0xc42087e780)
        /home/ben/.golang-path/src/golang.org/x/tools/go/loader/loader.go:956 +0x35
    created by golang.org/x/tools/go/loader.(*importer).startLoad
        /home/ben/.golang-path/src/golang.org/x/tools/go/loader/loader.go:958 +0x1e8
    
  4. What did you expect to see?
    The SSA representation of the program

  5. What did you see instead?
    panic: runtime error: index out of range followed by a stack trace

@josharian
Copy link
Contributor

@josharian josharian commented Aug 27, 2016

I recently touched sizes.go. Could be my fault.

Loading

@alandonovan alandonovan changed the title x/tools/cmd/ssadump: crash on any input go/types: crash in unsafe.Offsetof Aug 29, 2016
@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Aug 29, 2016

Looks like Offsetof is very broken:

$ go build golang.org/x/tools/cmd/gotype

$ cat ~/a.go
package a

import "unsafe"

const _ = unsafe.Offsetof(struct{ x int64 }{}.x)

$ ./gotype ~/a.go
struct{x int64} [] 0
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x62e960, 0xc42000e190)
        /usr/local/google/home/adonovan/go/src/runtime/panic.go:500 +0x1a0
main.checkPkgFiles.func2()
        /usr/local/google/home/adonovan/got3/src/golang.org/x/tools/cmd/gotype/gotype.go:211 +0x69
panic(0x62e960, 0xc42000e190)
        /usr/local/google/home/adonovan/go/src/runtime/panic.go:458 +0x241
go/types.(*Checker).handleBailout(0xc4200c61c0, 0xc4200d1d60)
        /usr/local/google/home/adonovan/go/src/go/types/check.go:213 +0xae
panic(0x62e960, 0xc42000e190)
        /usr/local/google/home/adonovan/go/src/runtime/panic.go:458 +0x241
go/types.(*Config).offsetof(0xc420010c80, 0x772640, 0xc420012ea0, 0xc42000eab0, 0x1, 0x1, 0xc4200157c0)
        /usr/local/google/home/adonovan/go/src/go/types/sizes.go:197 +0x250
go/types.(*Checker).builtin(0xc4200c61c0, 0xc420010e40, 0xc420010c00, 0x10, 0x0)
        /usr/local/google/home/adonovan/go/src/go/types/builtins.go:567 +0x44e9
go/types.(*Checker).call(0xc4200c61c0, 0xc420010e40, 0xc420010c00, 0x0)
        /usr/local/google/home/adonovan/go/src/go/types/call.go:44 +0x6ae
...

Loading

@griesemer griesemer added this to the Go1.8Early milestone Aug 29, 2016
@griesemer griesemer self-assigned this Aug 29, 2016
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 29, 2016

@josharian Checking out commit 133d231 just before the Sizeof cache removal (df9eeb1) seems to fix the problem. Assigning to you.

Loading

@griesemer griesemer assigned josharian and unassigned alandonovan and griesemer Aug 29, 2016
@josharian
Copy link
Contributor

@josharian josharian commented Aug 29, 2016

Sorry for the delay on this. CL 28070

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 30, 2016

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

Loading

@gopherbot gopherbot closed this in 6c6ad08 Aug 30, 2016
@golang golang locked and limited conversation to collaborators Aug 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants