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, types2: internal compiler error: panic: Config.Sizes.Sizeof returned a size < 0 #59190

Closed
Sundal4 opened this issue Mar 23, 2023 · 6 comments
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Sundal4
Copy link

Sundal4 commented Mar 23, 2023

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

$ go version 1.20

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env

What did you do?

https://go.dev/play/p/bF8KMRTERIW

What did you expect to see?

Errors are reported.

What did you see instead?

<unknown line number>: internal compiler error: panic: Config.Sizes.Sizeof returned a size < 0
@cuonglm cuonglm changed the title <unknown line number>: internal compiler error: panic: Config.Sizes.Sizeof returned a size < 0 go/types, types2: internal compiler error: panic: Config.Sizes.Sizeof returned a size < 0 Mar 23, 2023
@cuonglm cuonglm added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 23, 2023
@cuonglm cuonglm added this to the Go1.21 milestone Mar 23, 2023
@cuonglm
Copy link
Member

cuonglm commented Mar 23, 2023

cc @mdempsky @griesemer

@go101
Copy link

go101 commented Mar 23, 2023

The minimum case:

package main

import "unsafe"

type A [1 << 33]byte

type T [1 << 30]A

func main() {
	var t T
	println(unsafe.Sizeof(t))
}

But the following code doesn't cause compiler crashes:

package main

import "unsafe"

type A [1 << 33]byte

type T [1 << 31]A

func main() {
	var t T
	println(unsafe.Sizeof(t))
}

BTW2, the following code also doesn't cause compiler crashes, but the error message looks not good:

type T [1 << 63]byte // error: array length 1 << 63 (untyped int constant 9223372036854775808) must be integer

@griesemer griesemer self-assigned this Mar 23, 2023
@griesemer griesemer added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Mar 23, 2023
@griesemer
Copy link
Contributor

Thanks for reporting. The case that doesn't produce a crash is a different issue. Filed #59207 for that.

@gopherbot
Copy link

Change https://go.dev/cl/478919 mentions this issue: go/types, types2: don't panic if unsafe.Sizeof/Offsetof is used with oversize types

@griesemer
Copy link
Contributor

I filed #59209 for the case that produces a bad error message ((untyped int constant 9223372036854775808) must be integer).

@gopherbot
Copy link

Change https://go.dev/cl/479116 mentions this issue: cmd/compile: don't panic if unsafe.Sizeof/Offsetof is used with oversize types

@golang golang locked and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants