jmattheis / goverter

Generate type-safe Go converters by simply defining an interface
https://goverter.jmattheis.de/
MIT License
502 stars 47 forks source link

Segfault with useZeroValueOnPointerInconsistency #135

Closed NinjaPerson24119 closed 7 months ago

NinjaPerson24119 commented 7 months ago

Describe the bug A clear and concise description of what the bug is.

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference

when running with -g "useZeroValueOnPointerInconsistency yes"

To Reproduce Include the input file that goverter has problems with, and describe the steps you took to trigger the bug

unfortunately I'm not sure what the root cause is, and I can't share my code as it's private

as per usual, this could be an issue on my end as well, but want to raise awareness in case something jumps out to you about a potential cause

Expected behavior A clear and concise description of what you expected to happen.

Not segfault


Partial stacktrace

goroutine 68 [running]:
go/types.(*Checker).handleBailout(0xc0001f8a00, 0xc00096fc10)
        /usr/lib/go/src/go/types/check.go:367 +0x88
panic({0x68a200?, 0x8a95c0?})
        /usr/lib/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x737f48, 0x8ac780})
        /usr/lib/go/src/go/types/sizes.go:228 +0x31e
go/types.(*Config).sizeof(...)
        /usr/lib/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0x737f48?, 0x8ac780?})
        /usr/lib/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0x738ff8, 0x8a1f60}, 0xc0001f8a00, 0x8ac780, 0xc00096c848)
        /usr/lib/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc0001f8a00, 0xc00095de00, 0x8ac780)
        /usr/lib/go/src/go/types/const.go:256 +0x65
NinjaPerson24119 commented 7 months ago

Actually, segfaults regardless of useZeroValue option

NinjaPerson24119 commented 7 months ago

Interesting, so this appears to be a Go 1.22 issue. I downgraded my binary to Go 1.21.7 and it works as expected.

jmattheis commented 7 months ago

Could you try out the latest main branch?

I think I already fixed this one, but it isn't released yet.

NinjaPerson24119 commented 7 months ago

Can confirm:

jmattheis commented 7 months ago

Awesome thanks for trying it. I'll release this on the weekend.

jmattheis commented 7 months ago

Fixed with v1.4.0.