Skip to content

evalv3: nil pointer dereference with a unification involving optional fields and defaults #3411

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

Closed
mvdan opened this issue Aug 30, 2024 · 0 comments
Labels
evaluator evalv3 issues affecting only the evaluator version 3 panic

Comments

@mvdan
Copy link
Member

mvdan commented Aug 30, 2024

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

$ cue version
cue version v0.11.0-0.dev.0.20240830123612-3deadcefdda8

go version devel go1.24-9e8ea567c8 2024-08-28 21:03:29 +0000
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,randseednop=0,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v3
             vcs git
    vcs.revision 3deadcefdda82d7347116c5fdda886f87c2ba169
        vcs.time 2024-08-30T12:36:12Z
    vcs.modified false
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

It reproduces on master.

What did you do?

env CUE_EXPERIMENT=
exec cue export input.cue
cmp stdout export.stdout

env CUE_EXPERIMENT=evalv3
exec cue export input.cue
cmp stdout export.stdout

-- input.cue --
x: y?: [...string]
x: {y: ["foo"]} | *{y: ["bar"]}
-- export.stdout --
{
    "x": {
        "y": [
            "bar"
        ]
    }
}

What did you expect to see?

The same behavior with the old and new evaluators.

What did you see instead?

> env CUE_EXPERIMENT=evalv3
> exec cue export input.cue
[stderr]
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6dd639]

goroutine 1 gp=0xc000002380 m=4 mp=0xc000083508 [running]:
panic({0xd20060?, 0x1501540?})
	/home/mvdan/tip/src/runtime/panic.go:804 +0x168 fp=0xc00038fdc0 sp=0xc00038fd10 pc=0x472788
cuelang.org/go/internal/core/adt.runTask.func1()
	/home/mvdan/src/c/cue/internal/core/adt/sched.go:695 +0x76 fp=0xc00038fde8 sp=0xc00038fdc0 pc=0x727db6
panic({0xd20060?, 0x1501540?})
	/home/mvdan/tip/src/runtime/panic.go:785 +0x132 fp=0xc00038fe98 sp=0xc00038fde8 pc=0x472752
runtime.panicmem(...)
	/home/mvdan/tip/src/runtime/panic.go:262
runtime.sigpanic()
	/home/mvdan/tip/src/runtime/signal_unix.go:900 +0x359 fp=0xc00038fef8 sp=0xc00038fe98 pc=0x4749d9
cuelang.org/go/internal/core/adt.(*Vertex).updateArcType(0xc00018b180, 0x3?)
	/home/mvdan/src/c/cue/internal/core/adt/composite.go:332 +0x79 fp=0xc00038ff60 sp=0xc00038fef8 pc=0x6dd639
cuelang.org/go/internal/core/adt.(*nodeContext).getArc(0x72c4f4?, 0x4f?, 0x0?)
	/home/mvdan/src/c/cue/internal/core/adt/fields.go:332 +0x59 fp=0xc00038fff0 sp=0xc00038ff60 pc=0x71efd9
cuelang.org/go/internal/core/adt.(*nodeContext).insertArcCC(0xc0001ac608, 0x4c1, 0x0, {0xc000454aa0, {0xf72a78, 0xc0004542c0}, {0x0, 0xc0001910e0, 0x0, 0x0, ...}}, ...)
	/home/mvdan/src/c/cue/internal/core/adt/fields.go:800 +0xb3 fp=0xc000390140 sp=0xc00038fff0 pc=0x720f13
cuelang.org/go/internal/core/adt.(*nodeContext).insertArc(...)
	/home/mvdan/src/c/cue/internal/core/adt/fields.go:779
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleStruct(0xc0001ac608, 0xc000454320, 0xc000347440, {0x0, 0xc0001910e0, 0x0, 0x0, 0x0, 0x0, {0x0, ...}})
	/home/mvdan/src/c/cue/internal/core/adt/conjunct.go:298 +0xce5 fp=0xc0003902f0 sp=0xc000390140 pc=0x6e7845
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc0001ac608, {0xc000454320, {0xf728f8, 0xc000347440}, {0x0, 0xc0001910e0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
	/home/mvdan/src/c/cue/internal/core/adt/conjunct.go:172 +0x996 fp=0xc000390558 sp=0xc0003902f0 pc=0x6e5db6
cuelang.org/go/internal/core/adt.(*nodeContext).doDisjunct(0xc00018f808, {0xc000454320, {0xf728f8, 0xc000347440}, {0x0, 0xc0001910e0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
	/home/mvdan/src/c/cue/internal/core/adt/disjunct2.go:436 +0x4f8 fp=0xc000390768 sp=0xc000390558 pc=0x6ff578
cuelang.org/go/internal/core/adt.(*nodeContext).crossProduct(0xc00018f808, {0xc0003909d8?, 0xc0001903c0?, 0xc000192480?}, {0xc000390a70, 0x1, 0x8?}, 0xc0004242a0, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/disjunct2.go:345 +0x3c5 fp=0xc000390920 sp=0xc000390768 pc=0x6fecc5
cuelang.org/go/internal/core/adt.(*nodeContext).processDisjunctions(0xc00018f808)
	/home/mvdan/src/c/cue/internal/core/adt/disjunct2.go:279 +0x165 fp=0xc000390a90 sp=0xc000390920 pc=0x6fe565
cuelang.org/go/internal/core/adt.processDisjunctions(0x0?, 0xc00018abe0, 0xa5?)
	/home/mvdan/src/c/cue/internal/core/adt/tasks.go:189 +0x1c fp=0xc000390ad0 sp=0xc000390a90 pc=0x72a73c
cuelang.org/go/internal/core/adt.runTask(0xc00018abe0, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/sched.go:715 +0x545 fp=0xc000390ce8 sp=0xc000390ad0 pc=0x727925
cuelang.org/go/internal/core/adt.(*scheduler).process(0xc00018f9d8, 0x7eff, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/sched.go:408 +0x21f fp=0xc000390db8 sp=0xc000390ce8 pc=0x726bff
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc00018aaa0, 0xc000192480, 0x7fff, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/unify.go:160 +0x2bf fp=0xc000391000 sp=0xc000390db8 pc=0x72c5ff
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc00018f208, 0x7fff, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/unify.go:504 +0x22c fp=0xc0003910a8 sp=0xc000391000 pc=0x72dd8c
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc00018aa00, 0xc000192480, 0x7fff, 0x4)
	/home/mvdan/src/c/cue/internal/core/adt/unify.go:227 +0x8a6 fp=0xc0003912f0 sp=0xc0003910a8 pc=0x72cbe6
cuelang.org/go/internal/core/adt.(*OpContext).unify(0x90?, 0xf728f8?, 0x3915f0?)
	/home/mvdan/src/c/cue/internal/core/adt/eval.go:158 +0x339 fp=0xc000391540 sp=0xc0003912f0 pc=0x7047d9
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(0x0?, 0xc000192480)
	/home/mvdan/src/c/cue/internal/core/adt/composite.go:821 +0x59 fp=0xc000391570 sp=0xc000391540 pc=0x6df419
cuelang.org/go/cue.newVertexRoot(0xc0002693c0, 0x1?, 0xc00018aa00)
	/home/mvdan/src/c/cue/cue/types.go:602 +0x25 fp=0xc000391598 sp=0xc000391570 pc=0x94c0c5
cuelang.org/go/cue.newValueRoot(0x0?, 0xc0003916b0?, {0xf7aa60?, 0xc00018aa00?})
	/home/mvdan/src/c/cue/cue/types.go:611 +0x3e fp=0xc000391670 sp=0xc000391598 pc=0x94c15e
cuelang.org/go/cue.(*Context).make(0xc0002693c0, 0xc00018aa00)
	/home/mvdan/src/c/cue/cue/context.go:252 +0x79 fp=0xc0003916d8 sp=0xc000391670 pc=0x93b439
cuelang.org/go/cue.(*Context).BuildInstances(0xc0002693c0, {0xc000391980, 0x1, 0x1e0?})
	/home/mvdan/src/c/cue/cue/context.go:150 +0x1e5 fp=0xc000391788 sp=0xc0003916d8 pc=0x93a745
[...]
@mvdan mvdan added the panic label Aug 30, 2024
@cueckoo cueckoo closed this as completed in aeb3bf3 Sep 5, 2024
@mvdan mvdan added evalv3 issues affecting only the evaluator version 3 evaluator labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluator evalv3 issues affecting only the evaluator version 3 panic
Projects
None yet
Development

No branches or pull requests

1 participant