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: panic when enabling reverseTypeInference with -lang=go1.17 #59639

Closed
findleyr opened this issue Apr 14, 2023 · 1 comment
Closed

go/types: panic when enabling reverseTypeInference with -lang=go1.17 #59639

findleyr opened this issue Apr 14, 2023 · 1 comment
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@findleyr
Copy link
Contributor

The following test crashes go/types:

// -reverseTypeInference -lang=go1.17

// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

func f[P any](P) {}

var v func(int) = f

Output:

    --- FAIL: TestFixedbugs/issueNNNNN.go (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	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=0x0 pc=0x573f55]

goroutine 471 [running]:
testing.tRunner.func1.2({0x697cc0, 0x8c5fa0})
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1548 +0x39f
panic({0x697cc0?, 0x8c5fa0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:913 +0x21f
go/types.(*Checker).handleBailout(0xc0001c4b40, 0xc0003b78e8)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:332 +0x88
panic({0x697cc0?, 0x8c5fa0?})
	/usr/local/google/home/rfindley/src/go/src/runtime/panic.go:913 +0x21f
go/types.(*Checker).funcInst(0xc0001c4b40, 0xc000262240, 0xc0002622c0?, 0xc000262300, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/call.go:29 +0x95
go/types.(*Checker).nonGeneric(0xc0001c4b40, {0x74dc88?, 0xc000262240?}, 0xc000262300)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1282 +0x145
go/types.(*Checker).rawExpr(0xc0001c4b40, {0x74dc88, 0xc000262240}, 0xc000262300, {0x74e4c0?, 0xc0001f1200?}, {0x0?, 0x0?}, 0x0)
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1257 +0x1e5
go/types.(*Checker).expr(0x40380b?, {0x74dc88?, 0xc000262240?}, 0x0?, {0x74e4c0?, 0xc0001f1200?})
	/usr/local/google/home/rfindley/src/go/src/go/types/expr.go:1787 +0x45
go/types.(*Checker).varDecl(0x695940?, 0xc0000b19e0, {0xc000057ee8?, 0x1, 0x1}, {0x74e430, 0xc0001f11e0}, {0x74e4c0, 0xc0001f1200})
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:513 +0x16c
go/types.(*Checker).objDecl(0xc0001c4b40, {0x7503f8, 0xc0000b19e0}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/decl.go:194 +0x95e
go/types.(*Checker).packageObjects(0xc0001c4b40)
	/usr/local/google/home/rfindley/src/go/src/go/types/resolver.go:662 +0x465
go/types.(*Checker).checkFiles(0xc0001c4b40, {0xc000057ec8, 0x1, 0x1})
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:362 +0x149
go/types.(*Checker).Files(...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check.go:337
go/types.(*Config).Check(0xc000262080?, {0x8bdc80?, 0x6?}, 0x0?, {0xc000057ec8, 0x1, 0x1}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/api.go:422 +0x7c
go/types_test.testFiles(0xc0000836c0, {0x0?, 0x0}, {0xc0003b7f50?, 0x1, 0x1}, {0xc0003a6768?, 0x1, 0x1}, 0x0, ...)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:188 +0x5e5
go/types_test.testPkg(0xc0000836c0, {0xc0000c1f50, 0x1, 0x1}, 0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:431 +0x20b
go/types_test.testDirFiles.func1(0x0?)
	/usr/local/google/home/rfindley/src/go/src/go/types/check_test.go:396 +0x3c
testing.tRunner(0xc0000836c0, 0xc0001f1080)
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 277
	/usr/local/google/home/rfindley/src/go/src/testing/testing.go:1648 +0x3ad

Fix incoming.

@findleyr findleyr self-assigned this Apr 14, 2023
@findleyr findleyr added this to the Go1.21 milestone Apr 14, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/484757 mentions this issue: go/types,types2: fix panic in reverse type inference when -lang<go1.18

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants