cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.15k stars 296 forks source link

evalv3: panic on reference to closed struct #3580

Open rogpeppe opened 6 days ago

rogpeppe commented 6 days ago

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

$ cue version
v0.11.0

Does this issue reproduce with the latest stable release?

Yes (incl v0.10.0)

What did you do?

env CUE_EXPERIMENT=evalv3
exec cue vet x.cue
-- x.cue --
x: close({
    a: _
    b: x.a
})

What did you expect to see?

Passing test

What did you see instead?

panic: incDependent: already closed: 0xc00193bc00 [recovered]
    panic: incDependent: already closed: 0xc00193bc00

goroutine 1 gp=0xc000002380 m=3 mp=0xc000076e08 [running]:
panic({0xedbd80?, 0xc00195e010?})
    /home/rogpeppe/go/src/runtime/panic.go:804 +0x168 fp=0xc0003f9050 sp=0xc0003f8fa0 pc=0x4763e8
cuelang.org/go/internal/core/adt.runTask.func1()
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/sched.go:695 +0x76 fp=0xc0003f9078 sp=0xc0003f9050 pc=0x732096
panic({0xedbd80?, 0xc00195e010?})
    /home/rogpeppe/go/src/runtime/panic.go:785 +0x132 fp=0xc0003f9128 sp=0xc0003f9078 pc=0x4763b2
cuelang.org/go/internal/core/adt.(*closeContext).incDependent(0xc00193bc00, 0xc001955c00, 0xc001938b58?, 0x0?)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:570 +0xa6 fp=0xc0003f9170 sp=0xc0003f9128 pc=0x72a346
cuelang.org/go/internal/core/adt.(*closeContext).getKeyedCC(0xc00193b000, 0xc001955c00, 0xc00193bc00, {0xc0?, 0x22?, 0x94?, 0x0?}, 0x0, 0x1)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:422 +0x315 fp=0xc0003f9258 sp=0xc0003f9170 pc=0x729875
cuelang.org/go/internal/core/adt.(*closeContext).assignConjunct(0x0?, 0x733b2b?, 0x521?, {0x0, {0x122a5f8, 0xc001938b40}, {0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:456 +0x56 fp=0xc0003f9368 sp=0xc0003f9258 pc=0x729af6
cuelang.org/go/internal/core/adt.(*closeContext).getKeyedCC(0xc00193b100, 0xc001955c00, 0xc00193bc00, {0x0?, 0xbc?, 0x93?, 0x0?}, 0x0, 0x1)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:396 +0x1f8 fp=0xc0003f9450 sp=0xc0003f9368 pc=0x729758
cuelang.org/go/internal/core/adt.(*closeContext).assignConjunct(0xc0019423b0?, 0x0?, 0x0?, {0x0, {0x122a5f8, 0xc001938b28}, {0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:456 +0x56 fp=0xc0003f9560 sp=0xc0003f9450 pc=0x729af6
cuelang.org/go/internal/core/adt.(*closeContext).getKeyedCC(0xc00193bd00, 0xc001955c00, 0xc00193bc00, {0x8?, 0x6e?, 0x7?, 0x0?}, 0x0, 0x1)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:396 +0x1f8 fp=0xc0003f9648 sp=0xc0003f9560 pc=0x729758
cuelang.org/go/internal/core/adt.(*closeContext).assignConjunct(0x41caf6?, 0x7e458d1e4790?, 0x8?, {0xc0019423e0, {0x122a620, 0xc0019421c0}, {0x0, 0xc00193bd00, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:456 +0x56 fp=0xc0003f9758 sp=0xc0003f9648 pc=0x729af6
cuelang.org/go/internal/core/adt.(*closeContext).insertConjunct(0x104a4c0?, 0xc001955c00, 0xc00193bc00, {0xc0019423e0, {0x122a620, 0xc0019421c0}, {0x0, 0xc00193bd00, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:761 +0x65 fp=0xc0003f97f8 sp=0xc0003f9758 pc=0x72ac65
cuelang.org/go/internal/core/adt.(*nodeContext).insertArcCC(0xc00195a608, 0x501, 0x0, {0xc0019423e0, {0x122a620, 0xc0019421c0}, {0x0, 0xc00193bd00, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:845 +0x205 fp=0xc0003f9948 sp=0xc0003f97f8 pc=0x72b0e5
cuelang.org/go/internal/core/adt.(*nodeContext).insertArc(...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/fields.go:804
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleStruct(0xc00195a608, 0xc001942260, 0xc000393950, {0x0, 0xc00193bd00, 0x0, 0x0, 0x0, 0x0, {0x0, ...}})
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:315 +0xda7 fp=0xc0003f9b30 sp=0xc0003f9948 pc=0x6eee27
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc00195a608, {0xc001942260, {0x122a478, 0xc000393950}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:178 +0x4d9 fp=0xc0003f9dc0 sp=0xc0003f9b30 pc=0x6ecdd9
cuelang.org/go/internal/core/adt.(*nodeContext).insertAndSkipConjuncts(0x417449?, {0xc0019423c0?, 0xc00193b700?, 0xc0003f9ee8?}, {0xc001942260, {0x122a478, 0xc000393950}, {0x0, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:485 +0x96 fp=0xc0003f9ea8 sp=0xc0003f9dc0 pc=0x6f0016
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleVertexConjuncts(0xc00195a608, {0xc001942260, {0x122a428, 0xc001940460}, {0x0, 0xc00193bd00, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:441 +0x665 fp=0xc0003fa058 sp=0xc0003f9ea8 pc=0x6efd65
cuelang.org/go/internal/core/adt.(*nodeContext).insertValueConjunct(0xc00195a608, 0xc001942260, {0x1236ae0, 0xc001940460}, {0x0, 0xc00193bd00, 0x0, 0x0, 0x0, 0x0, ...})
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:579 +0x594 fp=0xc0003fa3a8 sp=0xc0003fa058 pc=0x6f0b14
cuelang.org/go/internal/core/adt.(*nodeContext).insertValueConjunct(0xc00195a608, 0xc001942260, {0x1236ae0, 0xc001940640}, {0x0, 0xc00193bd00, 0x0, 0x0, 0x0, 0x0, ...})
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/conjunct.go:568 +0x1dc fp=0xc0003fa6f8 sp=0xc0003fa3a8 pc=0x6f075c
cuelang.org/go/internal/core/adt.processExpr(0xc001955c00?, 0xc0019403c0, 0x4?)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/tasks.go:94 +0x1e8 fp=0xc0003fa7d0 sp=0xc0003fa6f8 pc=0x734208
cuelang.org/go/internal/core/adt.runTask(0xc0019403c0, 0x4)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/sched.go:718 +0x545 fp=0xc0003fa9e8 sp=0xc0003fa7d0 pc=0x731c05
cuelang.org/go/internal/core/adt.(*scheduler).process(0xc00195a7d8, 0x7eff, 0x4)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/sched.go:408 +0x21f fp=0xc0003faab8 sp=0xc0003fa9e8 pc=0x730edf
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc001940320, 0xc001955c00, 0x7fff, 0x4)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/unify.go:183 +0x35f fp=0xc0003fada0 sp=0xc0003faab8 pc=0x73703f
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc00195a008, 0x7fff, 0x4)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/unify.go:534 +0x1df fp=0xc0003faf38 sp=0xc0003fada0 pc=0x73897f
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc001940280, 0xc001955c00, 0x7fff, 0x4)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/unify.go:260 +0x9e6 fp=0xc0003fb220 sp=0xc0003faf38 pc=0x7376c6
cuelang.org/go/internal/core/adt.(*OpContext).unify(0x90?, 0x122a478?, 0x3938c0?)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/eval.go:160 +0x1c6 fp=0xc0003fb4a0 sp=0xc0003fb220 pc=0x70d8e6
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(0x0?, 0xc001955c00)
    /home/rogpeppe/src/cuelabs/cue/internal/core/adt/composite.go:901 +0x59 fp=0xc0003fb4d0 sp=0xc0003fb4a0 pc=0x6e6599
cuelang.org/go/cue.newVertexRoot(0xc0002ca580, 0x7e458d1ebc58?, 0xc001940280)
    /home/rogpeppe/src/cuelabs/cue/cue/types.go:588 +0x25 fp=0xc0003fb4f8 sp=0xc0003fb4d0 pc=0x975c85
cuelang.org/go/cue.newValueRoot(0x0?, 0xc0003fb610?, {0x1232960?, 0xc001940280?})
    /home/rogpeppe/src/cuelabs/cue/cue/types.go:597 +0x3e fp=0xc0003fb5d0 sp=0xc0003fb4f8 pc=0x975d1e
cuelang.org/go/cue.(*Context).make(0xc0002ca580, 0xc001940280)
    /home/rogpeppe/src/cuelabs/cue/cue/context.go:252 +0x79 fp=0xc0003fb638 sp=0xc0003fb5d0 pc=0x965259
cuelang.org/go/cue.(*Context).BuildInstances(0xc0002ca580, {0xc0003fb8e0, 0x1, 0x1c0?})
    /home/rogpeppe/src/cuelabs/cue/cue/context.go:150 +0x1e5 fp=0xc0003fb6e8 sp=0xc0003fb638 pc=0x964565
cuelang.org/go/cmd/cue/cmd.buildInstances(0xc0002c2f30, {0xc0003fb8e0, 0x1, 0xc0000df6c8?}, 0x1)
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/common.go:718 +0x45 fp=0xc0003fb790 sp=0xc0003fb6e8 pc=0xe01385
cuelang.org/go/cmd/cue/cmd.parseArgs(0xc0002c2f30, {0xc0002bee80, 0x1, 0x1}, 0xc0002639a0)
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/common.go:597 +0xc3c fp=0xc0003fb8f8 sp=0xc0003fb790 pc=0xe001bc
cuelang.org/go/cmd/cue/cmd.doVet(0xc0002c2f30, {0xc0002bee80, 0x1, 0x1})
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/vet.go:92 +0x87 fp=0xc0003fb9f0 sp=0xc0003fb8f8 pc=0xe32347
cuelang.org/go/cmd/cue/cmd.newVetCmd.mkRunE.func1(0xc0002dd200?, {0xc0002bee80, 0x1, 0x1})
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/root.go:143 +0x3fd fp=0xc0003fbc48 sp=0xc0003fb9f0 pc=0xe31c9d
github.com/spf13/cobra.(*Command).execute(0xc0002f8f08, {0xc0002bee40, 0x1, 0x1})
    /home/rogpeppe/src/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa fp=0xc0003fbdd0 sp=0xc0003fbc48 pc=0x602c8a
github.com/spf13/cobra.(*Command).ExecuteC(0xc00026e308)
    /home/rogpeppe/src/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff fp=0xc0003fbea8 sp=0xc0003fbdd0 pc=0x60355f
github.com/spf13/cobra.(*Command).Execute(...)
    /home/rogpeppe/src/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0xc0002c2f30, {0x193da00?, 0xf3e9a0?})
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/root.go:370 +0x1c fp=0xc0003fbec0 sp=0xc0003fbea8 pc=0xe2fbfc
cuelang.org/go/cmd/cue/cmd.Main()
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/cmd/root.go:278 +0x95 fp=0xc0003fbf38 sp=0xc0003fbec0 pc=0xe2f755
main.main()
    /home/rogpeppe/src/cuelabs/cue/cmd/cue/main.go:24 +0x13 fp=0xc0003fbf50 sp=0xc0003fbf38 pc=0xe535f3
runtime.main()
    /home/rogpeppe/go/src/runtime/proc.go:283 +0x28b fp=0xc0003fbfe0 sp=0xc0003fbf50 pc=0x43fe4b
runtime.goexit({})
    /home/rogpeppe/go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc0003fbfe8 sp=0xc0003fbfe0 pc=0x47f181