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

cue segfault #1060

Closed
cueckoo opened this issue Jul 3, 2021 · 1 comment
Closed

cue segfault #1060

cueckoo opened this issue Jul 3, 2021 · 1 comment

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @yuzhichang in cuelang/cue#1060

What version of CUE are you using (cue version)?

$ cue version
cue version v0.4.0 linux/amd64

What did you do?

//poc_cue.go
package main

import (
	"fmt"

	"cuelang.org/go/cue"
)

type ab struct{ A, B int }

var r cue.Runtime

var x ab

func main() {
	conf := `{
		A: 6
		# B shall be no less than 3
		B: 2,
	}
	`
	i, _ := r.Compile("test", conf)
	_ = i.Value().Decode(&x)
	fmt.Println(x)
}

$ go run poc_cue.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x688e26]

goroutine 1 [running]:
panic(0x6ded80, 0x919b30)
	/usr/local/go/src/runtime/panic.go:1065 +0x565 fp=0xc000287e78 sp=0xc000287db0 pc=0x4354c5
runtime.panicmem()
	/usr/local/go/src/runtime/panic.go:212 +0x5b fp=0xc000287e98 sp=0xc000287e78 pc=0x43351b
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:734 +0x173 fp=0xc000287ed0 sp=0xc000287e98 pc=0x44a4d3
cuelang.org/go/cue.(*Instance).Value(0x0, 0x729e80, 0x4, 0x6cb480)
	/home/zhichyu/go/pkg/mod/cuelang.org/go@v0.4.0/cue/instance.go:213 +0x26 fp=0xc000287f28 sp=0xc000287ed0 pc=0x688e26
main.main()
	/home/zhichyu/notes/code/poc_cue2.go:23 +0x85 fp=0xc000287f88 sp=0xc000287f28 pc=0x6a6585
runtime.main()
	/usr/local/go/src/runtime/proc.go:225 +0x256 fp=0xc000287fe0 sp=0xc000287f88 pc=0x438116
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc000287fe8 sp=0xc000287fe0 pc=0x4684c1


@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @yuzhichang in cuelang/cue#1060 (comment)

I forget to check the returned error of r.Compile. Sorry.

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

No branches or pull requests

1 participant