-
-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Calling String() on a string type ast.Node is causing a panic (See "screenshots" section for panic).
In this case I am calling ast.Walk on a node to find the end position.
To Reproduce
It seems to be pretty finicky in what content triggers this, but I've extracted my real-world case and just put a bunch of garbage data instead of the actual stuff which gives the same error.
Changing things will cause it not to trigger.
https://go.dev/play/p/dXKs8iPIYp9
Screenshots
panic: strings: negative Repeat count
goroutine 1 [running]:
strings.Repeat({0x1043750?, 0x1f?}, 0x1040ed0?)
strings/strings.go:624 +0x585
github.com/goccy/go-yaml/ast.(*StringNode).String(0xc00032b180)
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:832 +0xe5
github.com/Azure/dalec.(*endPosVisitor).Visit(0xc000312ca0, {0x10595c0, 0xc00032b180})
github.com/Azure/dalec/sourcemap.go:104 +0xcb
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x10595c0, 0xc00032b180})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2149 +0x38
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059cc0, 0xc000340cf0})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2173 +0x667
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059740, 0xc000540f00})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2197 +0x69c
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059640, 0xc0004a8880})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2189 +0x6ff
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059740, 0xc000540f50})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2197 +0x69c
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059640, 0xc0004a88c0})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2189 +0x6ff
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059740, 0xc000540fa0})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2197 +0x69c
github.com/goccy/go-yaml/ast.Walk({0x10484e0?, 0xc000312ca0?}, {0x1059640, 0xc0004a8840})
github.com/goccy/go-yaml@v1.18.0/ast/ast.go:2189 +0x6ff
github.com/Azure/dalec.nodeToRange({0x1059640, 0xc0004a8840})
Version Variables
- Go version: 1.24.6
- go-yaml's Version: 1.18.0
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working