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/go2go: segfault in go2go playground #39693

Closed
davidthomas426 opened this issue Jun 18, 2020 · 3 comments
Closed

cmd/go2go: segfault in go2go playground #39693

davidthomas426 opened this issue Jun 18, 2020 · 3 comments
Assignees
Labels
Milestone

Comments

@davidthomas426
Copy link
Contributor

@davidthomas426 davidthomas426 commented Jun 18, 2020

What version of Go are you using (go version)?

go2go playground

What did you do?

https://go2goplay.golang.org/p/EOl5XMwthzt

Even more pared down: https://go2goplay.golang.org/p/gGupo3meUf7

Just trying out generics for the first time. Used a type list in an interface, but I got the syntax wrong.

What did you expect to see?

Syntax error, like in this link: https://go2goplay.golang.org/p/e54jIQntO97

type checking failed for main
prog.go2:4:2: int is not an interface
prog.go2:4:7: float64 is not an interface

Go build failed.

What did you see instead?

Seg fault and panic

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x56ca7a]

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc00007c6c0, 0xc0000c9be0)
	/usr/local/go-faketime/src/go/types/check.go:251 +0x98
panic(0x64d840, 0x8048d0)
	/usr/local/go-faketime/src/runtime/panic.go:969 +0x175
go/types.(*Interface).Complete(0x0, 0x0)
	/usr/local/go-faketime/src/go/types/type.go:608 +0x3a
go/types.(*Interface).Complete(0xc000084700, 0xc000084700)
	/usr/local/go-faketime/src/go/types/type.go:637 +0x265
go/types.(*TypeParam).Bound(0xc000072740, 0xc000072740)
	/usr/local/go-faketime/src/go/types/type.go:819 +0x47
go/types.optype(0x6de060, 0xc000072740, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/type.go:831 +0x4e
go/types.(*TypeParam).Interface(0xc000072740, 0x6daa60)
	/usr/local/go-faketime/src/go/types/type.go:848 +0x37
go/types.(*Checker).varType(0xc00007c6c0, 0x6daa60, 0xc00000c320, 0xc0000c9460, 0x56d1ff)
	/usr/local/go-faketime/src/go/types/typexpr.go:131 +0x6d
go/types.(*Checker).collectParams(0xc00007c6c0, 0xc0000f3220, 0xc000010ba0, 0x0, 0x0, 0xc00000e201, 0x0, 0x0, 0x0, 0x6dda00)
	/usr/local/go-faketime/src/go/types/typexpr.go:691 +0x4c9
go/types.(*Checker).funcType(0xc00007c6c0, 0xc0000f4840, 0x0, 0xc00000c460)
	/usr/local/go-faketime/src/go/types/typexpr.go:326 +0x8c7
go/types.(*Checker).funcDecl(0xc00007c6c0, 0xc0000f30e0, 0xc0000f4780)
	/usr/local/go-faketime/src/go/types/decl.go:779 +0xc5
go/types.(*Checker).objDecl(0xc00007c6c0, 0x6de7e0, 0xc0000f30e0, 0x0)
	/usr/local/go-faketime/src/go/types/decl.go:200 +0xb85
go/types.(*Checker).packageObjects(0xc00007c6c0)
	/usr/local/go-faketime/src/go/types/resolver.go:644 +0x3a9
go/types.(*Checker).checkFiles(0xc00007c6c0, 0xc00003dcb8, 0x1, 0x1, 0x0, 0x0)
	/usr/local/go-faketime/src/go/types/check.go:280 +0x118
go/types.(*Checker).Files(...)
	/usr/local/go-faketime/src/go/types/check.go:256
go/types.(*Config).Check(0xc0000725c0, 0xc00001a3e0, 0x4, 0xc000072240, 0xc00003dcb8, 0x1, 0x1, 0xc000055360, 0x0, 0x4b6d2f, ...)
	/usr/local/go-faketime/src/go/types/api.go:387 +0x188
go/go2go.RewriteBuffer(0xc0000553b0, 0x7ffebe9a2dd8, 0x1e, 0xc0000b8000, 0xad, 0x2ad, 0x0, 0xc000010a50, 0xc000010a20, 0xc0000109f0, ...)
	/usr/local/go-faketime/src/go/go2go/go2go.go:127 +0x24f
main.translateFile(0xc0000553b0, 0x7ffebe9a2dd8, 0x1e)
	/usr/local/go-faketime/src/cmd/go2go/translate.go:26 +0xa9
main.main()
	/usr/local/go-faketime/src/cmd/go2go/main.go:64 +0x2ea

Go build failed.
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 18, 2020

Thanks. Clearly a bug in the type checker.

This works, as you probably have found out by now: https://go2goplay.golang.org/p/fe4_cqbpq_o

@griesemer griesemer self-assigned this Jun 18, 2020
@griesemer griesemer added the NeedsFix label Jun 18, 2020
@griesemer griesemer added this to the Unreleased milestone Jun 18, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 19, 2020

Change https://golang.org/cl/238858 mentions this issue: [dev.go2go] go/types: don't panic if an embedded type is not an interface

gopherbot pushed a commit that referenced this issue Jun 19, 2020
…face

Fixes #39693.

Change-Id: I7f2a4dd95edac3365a9b41b66afcd0015b5b836c
Reviewed-on: https://go-review.googlesource.com/c/go/+/238858
Reviewed-by: Robert Griesemer <gri@golang.org>
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 19, 2020

Fixed in dev.go2go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.