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

Segmentation fault when trying to create yaml out of a string #1086

Closed
bb-Ricardo opened this issue Jan 26, 2022 · 3 comments
Closed

Segmentation fault when trying to create yaml out of a string #1086

bb-Ricardo opened this issue Jan 26, 2022 · 3 comments
Labels

Comments

@bb-Ricardo
Copy link

Describe the bug
Hi,

I tried to generate a YAML file out of a string. Not sure if this command should work or not, but I assume it should not end in a SIGSEV.

Version of yq: 4.16.1
Operating system: OSX
Installed via: installed via homebrew

Command
The command you ran:

echo -e "a.a: a\na.b: b" | yq e -n  -s -

Actual behavior

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x124cdaf]

goroutine 1 [running]:
github.com/mikefarah/yq/v4/pkg/yqlib.(*resultsPrinter).PrintResults(0xc0001b6f50, 0xc0003f4e70)
	github.com/mikefarah/yq/v4/pkg/yqlib/printer.go:142 +0x42f
github.com/mikefarah/yq/v4/pkg/yqlib.(*streamEvaluator).Evaluate(0xc0002f5d88, {0x131f9ee, 0x1}, {0x1395780, 0xc000464660}, 0x15881c0, {0x139a3d0, 0xc0001b6f50}, {0x0, 0x0})
	github.com/mikefarah/yq/v4/pkg/yqlib/stream_evaluator.go:122 +0x446
github.com/mikefarah/yq/v4/pkg/yqlib.(*streamEvaluator).EvaluateFiles(0xc0002f5d88, {0x0, 0x0}, {0xc0002f5d48, 0x1, 0xc000141be0}, {0x139a3d0, 0xc0001b6f50}, 0x8)
	github.com/mikefarah/yq/v4/pkg/yqlib/stream_evaluator.go:72 +0x207
github.com/mikefarah/yq/v4/cmd.evaluateSequence(0xc000015680, {0xc0001138c0, 0x3, 0x3})
	github.com/mikefarah/yq/v4/cmd/evalute_sequence_command.go:116 +0x6da
github.com/spf13/cobra.(*Command).execute(0xc000015680, {0xc000113890, 0x3, 0x3})
	github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000015400)
	github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
	github.com/mikefarah/yq/v4/yq.go:11 +0x1e

Expected behavior

a:
  a: a
  b: b

Additional context
Add any other context about the problem here.

@mikefarah
Copy link
Owner

Please see this doc on syntax for creating yaml https://mikefarah.gitbook.io/yq/operators/create-collect-into-object#creating-yaml-from-scratch.

Though you have exposed a bug where yq isn't handling bad input well :)

@bb-Ricardo
Copy link
Author

I assumed I was using it wrong, found some of this in the 2.x version doc. Solved my config creation in a different way.

But a SIGSEV was still a surprise 😀

@mikefarah
Copy link
Owner

Seg fault fixed in 4.18.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants