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

compiler panics on unsafe.Offsetof of chan field #3083

Closed
ALTree opened this issue Aug 19, 2022 · 2 comments
Closed

compiler panics on unsafe.Offsetof of chan field #3083

ALTree opened this issue Aug 19, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@ALTree
Copy link

ALTree commented Aug 19, 2022

$ tinygo version
tinygo version 0.25.0 linux/amd64 (using go version go1.18.3 and LLVM version 14.0.0)
package main

import "unsafe"

func main() {
	var s struct{ f chan int }
	println(unsafe.Offsetof(s.f))
}
$ tinygo build crash.go
panic: unknown type: chan int [recovered]
	panic: unknown type: chan int

goroutine 1 [running]:
go/types.(*Checker).handleBailout(0xc0001ea000, 0xc000548a98)
	/__t/go/1.18.1/x64/src/go/types/check.go:303 +0x8b
panic({0x51d9da0, 0xc000324b70})
	/__t/go/1.18.1/x64/src/runtime/panic.go:838 +0x207
github.com/tinygo-org/tinygo/compiler.(*stdSizes).Sizeof(0xc0000285b8, {0x52c54f0?, 0xc000878138?})
	/__w/tinygo/tinygo/compiler/sizes.go:161 +0x387
github.com/tinygo-org/tinygo/compiler.(*stdSizes).Alignof(0xc0000285b8, {0x52c54f0, 0xc000878138})
	/__w/tinygo/tinygo/compiler/sizes.go:53 +0x17e
github.com/tinygo-org/tinygo/compiler.(*stdSizes).Offsetsof(0x52c54f0?, {0xc0009d80e0, 0x1, 0xc000878138?})
	/__w/tinygo/tinygo/compiler/sizes.go:72 +0xdd
go/types.(*Config).offsetsof(0x52c5608?, 0xc00031bc50)
	/__t/go/1.18.1/x64/src/go/types/sizes.go:229 +0x5c
go/types.(*Config).offsetof(0x52c5608?, {0x52c5608?, 0xc00031bc50?}, {0xc0002832f0, 0x1, 0x0?})
	/__t/go/1.18.1/x64/src/go/types/sizes.go:253 +0xa5
go/types.(*Checker).builtin(0xc0001ea000, 0xc0007ee940, 0xc00022f280, 0x11)
	/__t/go/1.18.1/x64/src/go/types/builtins.go:707 +0x4625
...
@dgryski
Copy link
Member

dgryski commented Aug 19, 2022

Thanks for the nice small reproduction case

@deadprogram deadprogram added the bug Something isn't working label Aug 21, 2022
aykevl added a commit that referenced this issue Aug 31, 2022
These types are simply pointers. For some reason, they were never
implemented.

Fixes #3083.
@aykevl
Copy link
Member

aykevl commented Aug 31, 2022

Yes, that's a very nice reproducer, thank you!
I have fixed the issue here: #3112

@deadprogram deadprogram added the next-release Will be part of next release label Sep 11, 2022
@aykevl aykevl closed this as completed in b485e8b Sep 29, 2022
@deadprogram deadprogram removed the next-release Will be part of next release label Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants