Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

go.tools/go/types assertion failure in recordTypeAndValue #8169

Closed
kardianos opened this issue Jun 7, 2014 · 5 comments
Closed

go.tools/go/types assertion failure in recordTypeAndValue #8169

kardianos opened this issue Jun 7, 2014 · 5 comments
Milestone

Comments

@kardianos
Copy link
Contributor

go.tools$ hg id
75a83badcaf5+ tip

$ go version
go version go1.3rc1 linux/amd64

When I run godoc with -analysis="(something)" -http="..." it crashes
in the analysis.

The following check appears to fail in go.tools/go/types/check.go:249:


func (check *checker) recordTypeAndValue(x ast.Expr, typ Type, val exact.Value) {
    assert(x != nil && typ != nil)
    if val != nil {
        assert(isConstType(typ)) // <- Fails here.
    }
    if m := check.Types; m != nil {
        m[x] = TypeAndValue{typ, val}
    }
}


If I hide:
github.com/youtube/vitess/go/zk/

Then the issue is not triggered.


panic: assertion failed [recovered]
    panic: assertion failed [recovered]
    panic: assertion failed [recovered]
    panic: assertion failed

goroutine 1463 [running]:
runtime.panic(0x901300, 0xc2183fdc70)
    /home/daniel/code/go/src/pkg/runtime/panic.c:279 +0xf5
code.google.com/p/go.tools/go/types.(*checker).handleBailout(0xc2178fd800, 0xc20b453250)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:202 +0xcd
runtime.panic(0x901300, 0xc2183fdc70)
    /home/daniel/code/go/src/pkg/runtime/panic.c:248 +0x18d
code.google.com/p/go.tools/go/types.(*checker).handleBailout(0xc217c42b00, 0xc20b452718)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:202 +0xcd
runtime.panic(0x901300, 0xc2183fdc70)
    /home/daniel/code/go/src/pkg/runtime/panic.c:248 +0x18d
code.google.com/p/go.tools/go/types.(*checker).handleBailout(0xc217d2c700, 0xc20b451be0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:202 +0xcd
runtime.panic(0x901300, 0xc2183fdc70)
    /home/daniel/code/go/src/pkg/runtime/panic.c:248 +0x18d
code.google.com/p/go.tools/go/types.assert(0x7f719be7f600)
    /home/daniel/src/code.google.com/p/go.tools/go/types/errors.go:18 +0x68
code.google.com/p/go.tools/go/types.(*checker).recordTypeAndValue(0xc217d2c700,
0x7f719be9abe8, 0xc217cd4de0, 0x7f719be7f6d0, 0xebbfc0, 0x7f719be7f698, 0x1)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:252 +0x70
code.google.com/p/go.tools/go/types.(*checker).rawExpr(0xc217d2c700, 0xc218499300,
0x7f719be9abe8, 0xc217cd4de0, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:938 +0x30b
code.google.com/p/go.tools/go/types.(*checker).use(0xc217d2c700, 0xc217cd0ab0, 0x1, 0x1)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:91 +0xd5
code.google.com/p/go.tools/go/types.(*checker).call(0xc217d2c700, 0xc218499280,
0xc217cdc1c0, 0xc217cdc1c0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:19 +0xad
code.google.com/p/go.tools/go/types.(*checker).exprInternal(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc1c0, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:1332 +0x244f
code.google.com/p/go.tools/go/types.(*checker).rawExpr(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc1c0, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:915 +0x84
code.google.com/p/go.tools/go/types.(*checker).expr(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc1c0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:1419 +0x64
code.google.com/p/go.tools/go/types.func·007(0xc218499280, 0x3)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:64 +0x7e
code.google.com/p/go.tools/go/types.(*checker).arguments(0xc217d2c700, 0xc218499280,
0xc217cdc200, 0xc21847a5d0, 0xc20b450600, 0x4)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:182 +0x90
code.google.com/p/go.tools/go/types.(*checker).call(0xc217d2c700, 0xc218499280,
0xc217cdc200, 0xc217cdc200)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:65 +0x826
code.google.com/p/go.tools/go/types.(*checker).exprInternal(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc200, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:1332 +0x244f
code.google.com/p/go.tools/go/types.(*checker).rawExpr(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc200, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:915 +0x84
code.google.com/p/go.tools/go/types.(*checker).expr(0xc217d2c700, 0xc218499280,
0x7f719be9ac20, 0xc217cdc200)
    /home/daniel/src/code.google.com/p/go.tools/go/types/expr.go:1419 +0x64
code.google.com/p/go.tools/go/types.func·002(0xc218499280, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/assignments.go:211 +0x77
code.google.com/p/go.tools/go/types.unpack(0xc20b450f10, 0x1, 0x42e301, 0xd0, 0xa240a0,
0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/call.go:121 +0x5f
code.google.com/p/go.tools/go/types.(*checker).initVars(0xc217d2c700, 0xc2183fdbe0, 0x2,
0x2, 0xc217cd0ac0, 0x1, 0x1, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/assignments.go:211 +0xc8
code.google.com/p/go.tools/go/types.(*checker).shortVarDecl(0xc217d2c700, 0x7c29cf,
0xc217cd4b60, 0x2, 0x2, 0xc217cd0ac0, 0x1, 0x1)
    /home/daniel/src/code.google.com/p/go.tools/go/types/assignments.go:310 +0x459
code.google.com/p/go.tools/go/types.(*checker).stmt(0xc217d2c700, 0x0, 0x7f719be9ac58,
0xc217cdc240)
    /home/daniel/src/code.google.com/p/go.tools/go/types/stmt.go:291 +0x4f23
code.google.com/p/go.tools/go/types.(*checker).stmtList(0xc217d2c700, 0x0, 0xc217cca480,
0x5, 0x8)
    /home/daniel/src/code.google.com/p/go.tools/go/types/stmt.go:91 +0x106
code.google.com/p/go.tools/go/types.(*checker).funcBody(0xc217d2c700, 0xc218154480,
0xc217cd0910, 0xd, 0xc2183f7440, 0xc217cd2f30)
    /home/daniel/src/code.google.com/p/go.tools/go/types/stmt.go:39 +0x158
code.google.com/p/go.tools/go/types.(*checker).functionBodies(0xc217d2c700)
    /home/daniel/src/code.google.com/p/go.tools/go/types/resolver.go:379 +0xf2
code.google.com/p/go.tools/go/types.(*checker).Files(0xc217d2c700, 0xc217c7cfc0, 0xb,
0xb, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:218 +0x10e
code.google.com/p/go.tools/go/loader.typeCheckFiles(0xc21798f0e0, 0xc217c7cfc0, 0xb, 0xb)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:745 +0x22d
code.google.com/p/go.tools/go/loader.(*importer).importFromSource(0xc209ad5e20,
0xc217c48a81, 0x26, 0x26, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:733 +0x11c
code.google.com/p/go.tools/go/loader.(*importer).importPackage(0xc209ad5e20,
0xc217c48a81, 0x26, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:693 +0x31b
code.google.com/p/go.tools/go/loader.(*importer).doImport(0xc209ad5e20, 0xc20984c5d0,
0xc217c48a81, 0x26, 0xc20b451e98, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:666 +0xc2
code.google.com/p/go.tools/go/loader.*importer.(code.google.com/p/go.tools/go/loader.doImport)·fm(0xc20984c5d0,
0xc217c48a81, 0x26, 0x26, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:763 +0x56
code.google.com/p/go.tools/go/types.(*checker).collectObjects(0xc217c42b00)
    /home/daniel/src/code.google.com/p/go.tools/go/types/resolver.go:166 +0x221d
code.google.com/p/go.tools/go/types.(*checker).Files(0xc217c42b00, 0xc217732f20, 0x15,
0x15, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:212 +0xb7
code.google.com/p/go.tools/go/loader.typeCheckFiles(0xc21798e870, 0xc217732f20, 0x15,
0x15)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:745 +0x22d
code.google.com/p/go.tools/go/loader.(*importer).importFromSource(0xc209ad5e20,
0xc2178e3e31, 0x28, 0x28, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:733 +0x11c
code.google.com/p/go.tools/go/loader.(*importer).importPackage(0xc209ad5e20,
0xc2178e3e31, 0x28, 0x0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:693 +0x31b
code.google.com/p/go.tools/go/loader.(*importer).doImport(0xc209ad5e20, 0xc20984c5d0,
0xc2178e3e31, 0x28, 0xc20b4529d0, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:666 +0xc2
code.google.com/p/go.tools/go/loader.*importer.(code.google.com/p/go.tools/go/loader.doImport)·fm(0xc20984c5d0,
0xc2178e3e31, 0x28, 0x28, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:763 +0x56
code.google.com/p/go.tools/go/types.(*checker).collectObjects(0xc2178fd800)
    /home/daniel/src/code.google.com/p/go.tools/go/types/resolver.go:166 +0x221d
code.google.com/p/go.tools/go/types.(*checker).Files(0xc2178fd800, 0xc21789d080, 0x6,
0x6, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/types/check.go:212 +0xb7
code.google.com/p/go.tools/go/loader.typeCheckFiles(0xc217883950, 0xc21789d080, 0x6, 0x6)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:745 +0x22d
code.google.com/p/go.tools/go/loader.(*importer).importFromSource(0xc209ad5e20,
0xc208647bd1, 0x26, 0x26, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:733 +0x11c
code.google.com/p/go.tools/go/loader.(*importer).importPackage(0xc209ad5e20,
0xc208647bd1, 0x26, 0xc20b453510, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:693 +0x31b
code.google.com/p/go.tools/go/loader.(*Config).Load(0xc2087161b0, 0x1, 0x0, 0x0)
    /home/daniel/src/code.google.com/p/go.tools/go/loader/loader.go:494 +0x253
code.google.com/p/go.tools/godoc/analysis.Run(0xa81501, 0xc20802ce70)
    /home/daniel/src/code.google.com/p/go.tools/godoc/analysis/analysis.go:341 +0xad0
created by main.main
    /home/daniel/src/code.google.com/p/go.tools/cmd/godoc/main.go:306 +0x177d
@ianlancetaylor
Copy link
Member

Comment 1:

Labels changed: added repo-tools, release-go1.4.

@adonovan
Copy link
Member

adonovan commented Jun 9, 2014

Comment 2:

kardianos: thanks for the bug report.
gri: the failing assertion's condition is false if the type is Invalid, which can be
caused by undefined symbol errors.  A minimal testcase is shown below.
% head src/[abc]/*.go
==> src/a/A.go <==
package a
==> src/b/B.go <==
package b
import "a"
const Z = a.X | a.Y
==> src/c/main.go <==
package main
import "b"
func main() {
        println(b.Z)
}
% GOPATH=. ./ssadump c
src/b/B.go:5:11: X not declared by package a
src/b/B.go:5:17: Y not declared by package a
panic: assertion failed [recovered]
        panic: assertion failed
goroutine 16 [running]:
runtime.panic(0x657a40, 0xc208000df0)
        /home/adonovan/go/src/pkg/runtime/panic.c:279 +0xf5
code.google.com/p/go.tools/go/types.(*checker).handleBailout(0xc208024000, 0xc2080b3790)
        /home/adonovan/got9/src/code.google.com/p/go.tools/go/types/check.go:202 +0xcd
runtime.panic(0x657a40, 0xc208000df0)
        /home/adonovan/go/src/pkg/runtime/panic.c:248 +0x18d
code.google.com/p/go.tools/go/types.assert(0x7f28a9e1f400)
        /home/adonovan/got9/src/code.google.com/p/go.tools/go/types/errors.go:18 +0x68
code.google.com/p/go.tools/go/types.(*checker).recordTypeAndValue(0xc208024000,
0x7f28a9e23c38, 0xc20800e760, 0x7f28a9e1f410, 0x8cd920, 0x7f28a9e1f3d8, 0x0)
        /home/adonovan/got9/src/code.google.com/p/go.tools/go/types/check.go:252 +0x70
code.google.com/p/go.tools/go/types.(*checker).rawExpr(0xc208024000, 0xc208049280,
0x7f28a9e23c38, 0xc20800e760, 0x0, 0x0, 0x0)
...

Owner changed to @griesemer.

@griesemer
Copy link
Contributor

Comment 3:

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 4:

Status changed to Duplicate.

Merged into issue #8518.

@griesemer
Copy link
Contributor

Comment 5:

This bug was fixed with 8518.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

6 participants