Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

cue segfault #1060

Closed
yuzhichang opened this issue Jun 16, 2021 · 2 comments
Closed

cue segfault #1060

yuzhichang opened this issue Jun 16, 2021 · 2 comments

Comments

@yuzhichang
Copy link

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


@yuzhichang
Copy link
Author

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

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#1060.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

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

No branches or pull requests

2 participants