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 while unmarshall #1050

Open
n-bes opened this issue Sep 25, 2024 · 0 comments
Open

panic while unmarshall #1050

n-bes opened this issue Sep 25, 2024 · 0 comments

Comments

@n-bes
Copy link

n-bes commented Sep 25, 2024

Instead of panic I expected just error. Repro:

$ go version
go version go1.23.1 darwin/arm64
package main

import (
	"gopkg.in/yaml.v3"
	"os"
)

type SomeStruct struct {
	data string `yaml:"data"`
}

func main() {
	someStruct := SomeStruct{}

	var data = []byte{
		0x34, 0x30, 0x79, 0x3a,
		0x3a, 0x0d, 0x0d, 0x0d,
		0x0d, 0x0d, 0x0d, 0x0d,
		0x0d, 0x3c, 0x3c, 0x3a,
		0x0d, 0x0d, 0x0d, 0x0d,
		0x0d, 0x0d, 0x0d, 0x2d,
		0x20, 0x20, 0x2d, 0x20,
		0x23, 0x0d, 0x3f, 0x0d,
		0x23, 0x0d, 0x0d, 0x23,
		0x2d, 0x0d, 0x20, 0x2d,
		0x0d, 0x3f, 0x0d, 0x23,
		0x0d, 0x0d, 0x23, 0x2d,
		0x2d,
	}
	yaml.Unmarshal(data, &someStruct)

	os.Exit(0)
}
panic: runtime error: hash of unhashable type []interface {} [recovered]
        panic: runtime error: hash of unhashable type []interface {}

goroutine 1 [running]:
gopkg.in/yaml%2ev3.handleErr(0x140000cfe88)
        /go/pkg/mod/gopkg.in/[email protected]/yaml.go:294 +0x80
panic({0x1044f1fe0?, 0x1400008e340?})
        /go/libexec/src/runtime/panic.go:785 +0x124
gopkg.in/yaml%2ev3.(*decoder).merge(0x140000c95e0, 0x140000d2320, 0x140000d25a0, {0x1044f3c20?, 0x1400008e230?, 0x0?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:966 +0x138
gopkg.in/yaml%2ev3.(*decoder).mappingStruct(0x140000c95e0, 0x140000d2320, {0x1044f3c20?, 0x1400008e230?, 0x8?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:950 +0xc28
gopkg.in/yaml%2ev3.(*decoder).mapping(0x140000c95e0, 0x140000d2320, {0x1044f3c20?, 0x1400008e230?, 0x0?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:786 +0x84
gopkg.in/yaml%2ev3.(*decoder).unmarshal(0x140000c95e0, 0x140000d2320, {0x1044f3c20?, 0x1400008e230?, 0x3?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:510 +0x364
gopkg.in/yaml%2ev3.(*decoder).document(...)
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:527
gopkg.in/yaml%2ev3.(*decoder).unmarshal(0x140000c95e0, 0x140000d2280, {0x1044f3c20?, 0x1400008e230?, 0x12b155228?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:498 +0x248
gopkg.in/yaml%2ev3.unmarshal({0x140000ae080, 0x31, 0x31}, {0x1044e7960, 0x1400008e230}, 0xac?)
        /go/pkg/mod/gopkg.in/[email protected]/yaml.go:167 +0x334
gopkg.in/yaml%2ev3.Unmarshal(...)
        /go/pkg/mod/gopkg.in/[email protected]/yaml.go:89
main.main()
        /random_project/main.go:30 +0xd8

Process finished with the exit code 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant