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

Panic when marshaling maps in Go 1.18 #6

Closed
flusflas opened this issue Mar 17, 2022 · 3 comments
Closed

Panic when marshaling maps in Go 1.18 #6

flusflas opened this issue Mar 17, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@flusflas
Copy link

flusflas commented Mar 17, 2022

Hi, I just updated to Go 1.18 and jettison (v0.7.3) started failing when marshaling maps. This code:

package main

import "github.com/wI2L/jettison"

func main() {
	jettison.Marshal(map[string]interface{}{
		"test": 123,
	})
}

will fail using Go 1.18 with this stacktrace:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x100 pc=0x460e05]

goroutine 1 [running]:
runtime.throw({0x4ca188?, 0xc00011c078?})
	/home/flusflas/.gvm/gos/go1.18/src/runtime/panic.go:992 +0x71 fp=0xc00008da38 sp=0xc00008da08 pc=0x430bd1
runtime.sigpanic()
	/home/flusflas/.gvm/gos/go1.18/src/runtime/signal_unix.go:802 +0x3a9 fp=0xc00008da88 sp=0xc00008da38 pc=0x444789
sync.(*Pool).Get(0x56b100)
	/home/flusflas/.gvm/gos/go1.18/src/sync/pool.go:129 +0x25 fp=0xc00008dac0 sp=0xc00008da88 pc=0x460e05
github.com/wI2L/jettison.encodeSortedMap(0x56b0c0, {0xc000138000, 0x1, 0x1000}, {{0x4e5730, 0xc00012c028}, {0x4c8fa0, 0x23}, 0x5, 0x0, ...}, ...)
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/encode.go:415 +0x7a fp=0xc00008dc00 sp=0xc00008dac0 pc=0x49a13a
github.com/wI2L/jettison.encodeMap(0x2?, {0xc000138000, 0x0, 0x1000}, {{0x4e5730, 0xc00012c028}, {0x4c8fa0, 0x23}, 0x5, 0x0, ...}, ...)
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/encode.go:364 +0x337 fp=0xc00008dce0 sp=0xc00008dc00 pc=0x499cd7
github.com/wI2L/jettison.newMapInstr.func1(0x56b000?, {0xc000138000?, 0xc00010c2b0?, 0xc000138000?}, {{0x4e5730, 0xc00012c028}, {0x4c8fa0, 0x23}, 0x5, 0x0, ...})
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/instruction.go:400 +0x72 fp=0xc00008dd70 sp=0xc00008dce0 pc=0x49ff52
github.com/wI2L/jettison.wrapInlineInstr.func1(0xc00010e150, {0xc000138000?, 0x203000?, 0x0?}, {{0x4e5730, 0xc00012c028}, {0x4c8fa0, 0x23}, 0x5, 0x0, ...})
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/instruction.go:406 +0x65 fp=0xc00008dde0 sp=0xc00008dd70 pc=0x4a0165
github.com/wI2L/jettison.marshalJSON({0x4b2a80?, 0xc00010e150?}, {{0x4e5730, 0xc00012c028}, {0x4c8fa0, 0x23}, 0x5, 0x0, 0x0, 0x0})
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/json.go:167 +0xd9 fp=0xc00008dea8 sp=0xc00008dde0 pc=0x4a0eb9
github.com/wI2L/jettison.Marshal({0x4b2a80?, 0xc00010e150?})
	/home/flusflas/go/pkg/mod/github.com/w!i2!l/jettison@v0.7.3/json.go:115 +0xbf fp=0xc00008df48 sp=0xc00008dea8 pc=0x4a0d7f
main.main()
	/home/flusflas/main/main.go:6 +0x7a fp=0xc00008df80 sp=0xc00008df48 pc=0x4a601a

I tried to look for any reported bug with pools in Go 1.18, but I didn't find anything, and I feel a little lost here.

@wI2L wI2L added the bug Something isn't working label Mar 17, 2022
@wI2L
Copy link
Owner

wI2L commented Mar 17, 2022

The runtime map iterator representation might have changed in 1.18. I'll have a look this week.

@wI2L
Copy link
Owner

wI2L commented Mar 17, 2022

Found the issue, it's related to a change in this PR: golang/go@1b2d794
Which only affect go.18, and further versions to come.

I'll release a fix in a new version shortly.

@flusflas
Copy link
Author

Wow, it was quick. Thanks!

@wI2L wI2L closed this as completed in 44bcb2d Mar 18, 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

2 participants