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/compile: internal compiler error: have Val #12686

Closed
rasky opened this issue Sep 18, 2015 · 5 comments
Closed

cmd/compile: internal compiler error: have Val #12686

rasky opened this issue Sep 18, 2015 · 5 comments

Comments

@rasky
Copy link
Member

rasky commented Sep 18, 2015

http://play.golang.org/p/kn1aiXuG0l

package main

import "fmt"

func Crash(used int) {
    data := []byte{(1 << (uint(used) & 7)) - 1}
    fmt.Println(data)
}
have Val [0xc82019f170]
.   SUB l(6) tc(1) byte
.   .   LSH l(6) tc(1) byte
.   .   .   LITERAL-1 l(6) tc(1) byte
.   .   .   AND l(6) tc(1) uint
.   .   .   .   CONV l(6) tc(1) uint
.   .   .   .   .   NAME-main.used u(1) a(true) g(1) l(5) x(0+0) class(PPARAM) f(1) ld(1) tc(1) used(true) int
.   .   .   .   LITERAL-7 l(6) tc(1) uint
.   .   LITERAL-1 l(6) tc(1) byte
prog.go:8: internal compiler error: have Val
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x5d3680]

goroutine 1 [running]:
cmd/compile/internal/gc.hcrash()
    /usr/local/go/src/cmd/compile/internal/gc/subr.go:105 +0x50
cmd/compile/internal/gc.Fatal(0x81ec90, 0x8, 0x0, 0x0, 0x0)
    /usr/local/go/src/cmd/compile/internal/gc/subr.go:198 +0x2b1
cmd/compile/internal/gc.(*Node).SetOpt(0xc82019f170, 0x77b9c0, 0xc820195530)
    /usr/local/go/src/cmd/compile/internal/gc/syntax.go:107 +0x97
cmd/compile/internal/gc.(*EscState).nodeEscState(0xc8201a6000, 0xc82019f170, 0x77b9c0)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:330 +0x1f6
cmd/compile/internal/gc.escwalk(0xc8201a6000, 0xc82019ffff, 0xc82019f290, 0xc82019f170)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:1590 +0x6d
cmd/compile/internal/gc.escwalk(0xc8201a6000, 0xc820190000, 0xc82019f290, 0xc82019ecf0)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:1710 +0x288c
cmd/compile/internal/gc.escflood(0xc8201a6000, 0xc82019f290)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:1575 +0x35f
cmd/compile/internal/gc.escAnalyze(0xc82017f680, 0xc820195200)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:456 +0x214
cmd/compile/internal/gc.(*bottomUpVisitor).visit(0xc820089ab0, 0xc82019e900, 0xc8201952c0)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:107 +0x297
cmd/compile/internal/gc.visitBottomUp(0xc82017f4a0, 0x89b080)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:62 +0xb0
cmd/compile/internal/gc.escapes(0xc82017f4a0)
    /usr/local/go/src/cmd/compile/internal/gc/esc.go:187 +0x2d
cmd/compile/internal/gc.Main()
    /usr/local/go/src/cmd/compile/internal/gc/lex.go:456 +0x1e65
cmd/compile/internal/amd64.Main()
    /usr/local/go/src/cmd/compile/internal/amd64/galign.go:127 +0x58d
main.main()
    /usr/local/go/src/cmd/compile/main.go:26 +0x189

Program exited.
@ianlancetaylor ianlancetaylor added this to the Go1.5.2 milestone Sep 19, 2015
@ianlancetaylor ianlancetaylor changed the title Go 1.5: internal compiler error: have Val cmd/compile: internal compiler error: have Val Sep 19, 2015
@ianlancetaylor
Copy link
Contributor

This is a compiler crash on valid code.

@minux
Copy link
Member

minux commented Sep 19, 2015 via email

@mwhudson
Copy link
Contributor

A slightly smaller test case is:

package foo

func Crash(a uint) uint {
    d := []uint{1 << a}
    return d[0]
}

The call to SetVal that makes the call to SetOpt explode later is from defaultlit. I don't understand what this is about at all :-) but it is setting the Val to nil; maybe setting Val to nil should not "count" when it comes to the checks SetOpt does?

@gopherbot
Copy link

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

@rsc rsc closed this as completed in 918a264 Nov 18, 2015
@gopherbot
Copy link

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

rsc added a commit that referenced this issue Nov 23, 2015
Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/17124
@golang golang locked and limited conversation to collaborators Nov 27, 2016
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

5 participants