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 (go-yaml/yaml issue #1050) #117

Open
pohly opened this issue Sep 28, 2024 · 0 comments
Open

panic while unmarshall (go-yaml/yaml issue #1050) #117

pohly opened this issue Sep 28, 2024 · 0 comments

Comments

@pohly
Copy link

pohly commented Sep 28, 2024

go-yaml/yaml#1050 applies to the fork:

package main

import (
	"fmt"

	yaml "sigs.k8s.io/yaml/goyaml.v3"
)

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,
	}
	fmt.Printf("%q\n", string(data))

	yaml.Unmarshal(data, &someStruct)
}
"40y::\r\r\r\r\r\r\r\r<<:\r\r\r\r\r\r\r-  - #\r?\r#\r\r#-\r -\r?\r#\r\r#--"
panic: runtime error: hash of unhashable type []interface {} [recovered]
	panic: runtime error: hash of unhashable type []interface {}

goroutine 1 [running]:
sigs.k8s.io/yaml/goyaml%2ev3.handleErr(0xc00014de78)
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/yaml.go:294 +0x6d
panic({0x507f80?, 0xc00011c230?})
	/nvme/gopath/go-1.23.0/src/runtime/panic.go:785 +0x132
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).merge(0xc0001435e0, 0xc000150320, 0xc0001505a0, {0x509d20?, 0xc00011c120?, 0x4e76e5?})
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:966 +0x1a5
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).mappingStruct(0xc0001435e0, 0xc000150320, {0x509d20?, 0xc00011c120?, 0xc00014db10?})
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:950 +0x1065
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).mapping(0xc0001435e0, 0xc000150320, {0x509d20?, 0xc00011c120?, 0x46251e?})
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:786 +0xa5
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).unmarshal(0xc0001435e0, 0xc000150320, {0x509d20?, 0xc00011c120?, 0x4d4385?})
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:510 +0x3ea
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).document(...)
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:527
sigs.k8s.io/yaml/goyaml%2ev3.(*decoder).unmarshal(0xc0001435e0, 0xc000150280, {0x509d20?, 0xc00011c120?, 0xc00014de78?})
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/decode.go:498 +0x28a
sigs.k8s.io/yaml/goyaml%2ev3.unmarshal({0xc00016c000, 0x31, 0x31}, {0x4fd8c0, 0xc00011c120}, 0x1?)
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/yaml.go:167 +0x396
sigs.k8s.io/yaml/goyaml%2ev3.Unmarshal(...)
	/nvme/gopath/src/k8s.io/kubernetes/vendor/sigs.k8s.io/yaml/goyaml.v3/yaml.go:89
main.main()
	/nvme/gopath/src/k8s.io/kubernetes/test2/main.go:33 +0x107
exit status 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