cue-lang / cue

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

evalv3: double closure of struct #3249

Closed alecholmez closed 6 days ago

alecholmez commented 1 month ago

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

cue version v0.9.2

go version go1.22.4
      -buildmode exe
       -compiler gc
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.9.2

Does this issue reproduce with the latest stable release?

Without the evalv3 experiment enabled, this does not reproduce. With evalv3 this can be reproduced.

What did you do?

CUE_EXPERIMENT=evalv3 cue eval -c ./...

What did you expect to see?

An evaluated project.

What did you see instead?

A panic:

CUE_EXPERIMENT=evalv3 cue eval -c ./...
panic: incDependent: already closed: 0xc0020da3c0 [recovered]
    panic: incDependent: already closed: 0xc0020da3c0 [recovered]
    panic: incDependent: already closed: 0xc0020da3c0

goroutine 1 [running]:
cuelang.org/go/internal/core/adt.runTask.func1()
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:692 +0x76
panic({0xc9d900?, 0xc0003d4300?})
    /usr/local/go/src/runtime/panic.go:770 +0x132
cuelang.org/go/internal/core/adt.runTask.func1()
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:692 +0x76
panic({0xc9d900?, 0xc0003d4300?})
    /usr/local/go/src/runtime/panic.go:770 +0x132
cuelang.org/go/internal/core/adt.(*closeContext).incDependent(0xc0020da3c0, 0xc000c26480, 0x6c0f5d?, 0x1485d70?)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/fields.go:533 +0xa9
cuelang.org/go/internal/core/adt.CloseInfo.spawnCloseContext({0x0, 0xc00176a1e0, 0x0, 0x0, 0x0, 0x0, {0x0, 0x0, 0xc001673710}}, 0xc000c26480, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/fields.go:471 +0xfc
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleVertexConjuncts(0xc002177208, {0xc000864d60, {0xf25b58, 0xc00031e000}, {0x0, 0xc0020da3c0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:399 +0x426
cuelang.org/go/internal/core/adt.(*nodeContext).unshare(0xc0021773d8?)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/share.go:48 +0x135
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc002177208, {0xc00137c5e0, {0xf259a0, 0xc0001f9560}, {0x0, 0xc00176a0f0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:171 +0x97e
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc002177208, {0xc00137c5e0, {0xf25ab8, 0xc0001ff3a0}, {0x0, 0xc001765950, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:160 +0x1566
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc002177208, {0x0, {0xf25a90, 0xc00175c8b8}, {0x0, 0xc001765860, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:137 +0x136c
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0xc002177208, {0x0, {0xf25a90, 0xc00175c8d0}, {0x0, 0xc001765770, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:137 +0x136c
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleVertexConjuncts(0xc002177208, {0xc000be9800, {0xf25b58, 0xc0002dde40}, {0x0, 0xc00108b770, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/conjunct.go:425 +0x676
cuelang.org/go/internal/core/adt.processResolver(0xc000c26480, 0xc000f954a0, 0x40?)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/tasks.go:122 +0x44c
cuelang.org/go/internal/core/adt.runTask(0xc000f954a0, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:712 +0x525
cuelang.org/go/internal/core/adt.(*scheduler).process(0xc0021773d8, 0x7eff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:411 +0x23d
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc0019912c0, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:159 +0x305
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc001086608, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:503 +0x230
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc0021d6140, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:226 +0x8e8
cuelang.org/go/internal/core/adt.(*nodeContext).doDisjunct(0xc000add208, {0xc0006ff420, {0xf25bd0, 0xc000433710}, {0x0, 0xc0013d4e10, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/disjunct2.go:441 +0x599
cuelang.org/go/internal/core/adt.(*nodeContext).crossProduct(0xc000add208, {0xc000e17e48?, 0xc000da1d88?, 0xc000da1f58?}, {0xc000e17f08, 0x1, 0xf25bd0?}, 0xc000ba89a0, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/disjunct2.go:345 +0x3e5
cuelang.org/go/internal/core/adt.(*nodeContext).processDisjunctions(0xc000add208)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/disjunct2.go:279 +0x176
cuelang.org/go/internal/core/adt.processDisjunctions(0xdc4135?, 0xc000c17860, 0x8?)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/tasks.go:189 +0x1c
cuelang.org/go/internal/core/adt.runTask(0xc000c17860, 0x2)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:712 +0x525
cuelang.org/go/internal/core/adt.(*scheduler).process(0xc000add3d8, 0x24, 0x2)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:411 +0x23d
cuelang.org/go/internal/core/adt.(*nodeContext).completeNodeTasks(0xc000add208, 0x2)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:390 +0x179
cuelang.org/go/internal/core/adt.runTask.func1()
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:678 +0x30
cuelang.org/go/internal/core/adt.runTask(0xc000813720, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:734 +0x6df
cuelang.org/go/internal/core/adt.(*scheduler).process(0xc000add3d8, 0x7eff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/sched.go:411 +0x23d
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc0008121e0, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:159 +0x305
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc00073f808, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:503 +0x230
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc0002b4000, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:226 +0x8e8
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc000737208, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:503 +0x230
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc00014f680, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:226 +0x8e8
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0xc000736c08, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:503 +0x230
cuelang.org/go/internal/core/adt.(*Vertex).unify(0xc00014f5e0, 0xc000c26480, 0x7fff, 0x4)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/unify.go:226 +0x8e8
cuelang.org/go/internal/core/adt.(*OpContext).unify(0x0?, 0x0?, 0xf2ebd0?)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/eval.go:158 +0x386
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(0x41389b?, 0xc000c26480)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/internal/core/adt/composite.go:816 +0x59
cuelang.org/go/cue.newVertexRoot(0xc00029f740, 0x0?, 0xc00014f5e0)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cue/types.go:602 +0x25
cuelang.org/go/cue.newValueRoot(0x0?, 0xc000c89628?, {0xf2cee0?, 0xc00014f5e0?})
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cue/types.go:611 +0x3e
cuelang.org/go/cue.(*Context).make(0xc00029f740, 0xc00014f5e0)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cue/context.go:257 +0x8c
cuelang.org/go/cue.(*Context).BuildInstances(0xc00029f740, {0xc000548f90, 0x2, 0xb80000000041c7b8?})
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cue/context.go:152 +0x1e5
cuelang.org/go/cmd/cue/cmd.buildInstances(0xc0002e5a70, {0xc000548f90, 0x2, 0x10?}, 0x0)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/common.go:710 +0x46
cuelang.org/go/cmd/cue/cmd.(*buildPlan).instances(0xc00036c1a0)
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/common.go:140 +0x48
cuelang.org/go/cmd/cue/cmd.runEval(0xc0002e5a70, {0xc0002918c0, 0x1, 0x2})
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/eval.go:117 +0x3aa
cuelang.org/go/cmd/cue/cmd.newEvalCmd.mkRunE.func1(0xc0001c4a00?, {0xc0002918c0, 0x1, 0x2})
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/root.go:125 +0x2ac
github.com/spf13/cobra.(*Command).execute(0xc0002f4f08, {0xc0002918a0, 0x2, 0x2})
    /home/alec-holmes/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002f4608)
    /home/alec-holmes/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
    /home/alec-holmes/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0xc0002e5a70, {0x151b300?, 0xce32a0?})
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/root.go:377 +0x1f
cuelang.org/go/cmd/cue/cmd.Main()
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/cmd/root.go:285 +0x95
main.main()
    /home/alec-holmes/go/pkg/mod/cuelang.org/go@v0.9.2/cmd/cue/main.go:24 +0x13
alecholmez commented 1 month ago

I can provide the source code privately when needed. Thanks!

mvdan commented 1 month ago

Thanks @alecholmez - I'll post a comment here once I have a small reproducer from what you shared.

nyarly commented 1 month ago

I'm having a similar problem, which @rogpeppe was able to reduce to:

env CUE_EXPERIMENT=evalv3
exec cue eval repro.cue

repro.cue

package repro

#P: c: {
    let m = {[string]: _}
    x:  m
}

a: (#P & {}).c
a: (#P & {}).c
mvdan commented 3 weeks ago

Joining threads - the bug that @nyarly mentions is #3255, and the two panics are not identical but extremely similar, so I suggest we fix 3255 first as it already has a minimal reproducer, and then come back here to see whether it also fixes @alecholmez's code that he shared with us. If it doesn't, I will reduce his reproducer as well.

alecholmez commented 2 weeks ago

More than happy to test a fix!

alecholmez commented 2 weeks ago

Just a heads up I ran this against v0.10.0-alpha.1 and received a new panic:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    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=0x2 addr=0x1d0 pc=0x100a72a5c]

goroutine 1 [running]:
cuelang.org/go/internal/core/adt.runTask.func1()
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:692 +0xa4
panic({0x10117aca0?, 0x101794ff0?})
    /opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/panic.go:770 +0x124
cuelang.org/go/internal/core/adt.runTask.func1()
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:692 +0xa4
panic({0x10117aca0?, 0x101794ff0?})
    /opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/panic.go:770 +0x124
cuelang.org/go/internal/core/adt.(*Vertex).updateArcType(0x1403bed7c20, 0x84?)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/composite.go:321 +0x6c
cuelang.org/go/internal/core/adt.(*nodeContext).getArc(0x1401946ae78?, 0x7e4318?, 0x1?)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/fields.go:323 +0x74
cuelang.org/go/internal/core/adt.(*nodeContext).insertArcCC(0x1403beeb808, 0xad51, 0x0, {0x1400b9d9c40, {0x10125e998, 0x1400086a120}, {0x0, 0x1403bef24b0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/fields.go:774 +0x9c
cuelang.org/go/internal/core/adt.(*nodeContext).insertArc(...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/fields.go:753
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleStruct(0x1403beeb808, 0x1400b7811c0, 0x140002b8510, {0x0, 0x1403bef24b0, 0x0, 0x0, 0x0, 0x0, {0x0, ...}})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:298 +0xa20
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0x1403beeb808, {0x1400b7811c0, {0x10125e998, 0x1400086a2e0}, {0x0, 0x1403bb92d20, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:172 +0x79c
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0x1403beeb808, {0x0, {0x10125e970, 0x1403bb69740}, {0x0, 0x1403bb92c30, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:137 +0xf90
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0x1403beeb808, {0x0, {0x10125e970, 0x1403bb69758}, {0x0, 0x1403bb92b40, 0x0, 0x0, 0x1, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:137 +0xf90
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0x1403beeb808, {0x0, {0x10125e970, 0x1403bb69770}, {0x0, 0x1403bb92a50, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:137 +0xf90
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleConjunct(0x1403beeb808, {0x0, {0x10125e970, 0x1403bb69788}, {0x0, 0x1403bb92960, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:137 +0xf90
cuelang.org/go/internal/core/adt.(*nodeContext).scheduleVertexConjuncts(0x1403beeb808, {0x1400b7811c0, {0x10125eab0, 0x14000825840}, {0x0, 0x1403beb14a0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/conjunct.go:425 +0x498
cuelang.org/go/internal/core/adt.processResolver(0x1400fddbb00, 0x1403bef4a00, 0xb0?)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/tasks.go:122 +0x394
cuelang.org/go/internal/core/adt.runTask(0x1403bef4a00, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:712 +0x434
cuelang.org/go/internal/core/adt.(*scheduler).process(0x1403beeb9d8, 0x7eff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:411 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x1403be74140, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:159 +0x220
cuelang.org/go/internal/core/adt.(*nodeContext).doDisjunct(0x1403bd2ac08, {0x1400b7811c0, {0x10125eab0, 0x14000825840}, {0x0, 0x1403beb14a0, 0x0, 0x0, 0x0, 0x0, ...}}, ...)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/disjunct2.go:441 +0x490
cuelang.org/go/internal/core/adt.(*nodeContext).crossProduct(0x1403bc6f208, {0x1401946d8f8?, 0x1403bc7a690?, 0x1400fddbb00?}, {0x1400b9b1a00, 0x3, 0x1401946d7c8?}, 0x14038402a10, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/disjunct2.go:345 +0x2ec
cuelang.org/go/internal/core/adt.(*nodeContext).processDisjunctions(0x1403bc6f208)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/disjunct2.go:279 +0x118
cuelang.org/go/internal/core/adt.processDisjunctions(0x100f6fbde?, 0x1403bc78780, 0x6?)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/tasks.go:189 +0x24
cuelang.org/go/internal/core/adt.runTask(0x1403bc78780, 0x2)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:712 +0x434
cuelang.org/go/internal/core/adt.(*scheduler).process(0x1403bc6f3d8, 0x24, 0x2)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:411 +0x1dc
cuelang.org/go/internal/core/adt.(*nodeContext).completeNodeTasks(0x1403bc6f208, 0x2)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:390 +0x13c
cuelang.org/go/internal/core/adt.runTask.func1()
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:678 +0x38
cuelang.org/go/internal/core/adt.runTask(0x1403bc78000, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:734 +0x5b4
cuelang.org/go/internal/core/adt.(*scheduler).process(0x1403bc6f3d8, 0x7eff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/sched.go:411 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x1403bc29a40, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:159 +0x220
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0x1403bb7f808, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:503 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x1403bb75040, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:226 +0x738
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0x14022d25208, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:503 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x14022d12e60, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:226 +0x738
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x14023b0be00, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:283 +0x9c0
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0x14022d24008, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:503 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x14022d12c80, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:226 +0x738
cuelang.org/go/internal/core/adt.(*nodeContext).completeAllArcs(0x14022d19208, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:503 +0x1dc
cuelang.org/go/internal/core/adt.(*Vertex).unify(0x14022d12b40, 0x1400fddbb00, 0x7fff, 0x4)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/unify.go:226 +0x738
cuelang.org/go/internal/core/adt.(*OpContext).unify(0x140003d0000?, 0x0?, 0x1?)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/eval.go:158 +0x320
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(0x1401c79f4b8?, 0x1400fddbb00)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/internal/core/adt/composite.go:816 +0x58
cuelang.org/go/cue.newVertexRoot(0x1400021b740, 0x10921fe88?, 0x14022d12b40)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cue/types.go:602 +0x2c
cuelang.org/go/cue.newValueRoot(0x0?, 0x1401c79f5d0?, {0x101265c40?, 0x14022d12b40?})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cue/types.go:611 +0x3c
cuelang.org/go/cue.(*Context).make(0x1400021b740, 0x14022d12b40)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cue/context.go:253 +0x8c
cuelang.org/go/cue.(*Context).BuildInstances(0x1400021b740, {0x14000ae8da0, 0x3, 0x14000adf810?})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cue/context.go:148 +0x1ac
cuelang.org/go/cmd/cue/cmd.buildInstances(0x14000281ad0, {0x14000ae8da0, 0x3, 0x14000700908?}, 0x0)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/common.go:710 +0x38
cuelang.org/go/cmd/cue/cmd.(*buildPlan).instances(0x14000326820)
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/common.go:140 +0x44
cuelang.org/go/cmd/cue/cmd.runEval(0x14000281ad0, {0x140002138c0, 0x1, 0x2})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/eval.go:117 +0x2ec
cuelang.org/go/cmd/cue/cmd.newEvalCmd.mkRunE.func1(0x1400018ca00?, {0x140002138c0, 0x1, 0x2})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/root.go:126 +0x1fc
github.com/spf13/cobra.(*Command).execute(0x14000282f08, {0x140002138a0, 0x2, 0x2})
    /Users/alecholmes/Developer/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x14000282608)
    /Users/alecholmes/Developer/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/alecholmes/Developer/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0x14000281ad0, {0x1018368e0?, 0x10117bcc0?})
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/root.go:391 +0x28
cuelang.org/go/cmd/cue/cmd.Main()
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/cmd/root.go:299 +0x9c
main.main()
    /Users/alecholmes/Developer/go/pkg/mod/cuelang.org/go@v0.10.0-alpha.1/cmd/cue/main.go:24 +0x1c
alecholmez commented 1 week ago

@mvdan This issue seems to be solved with the latest v0.10.0-alpha.2 release but a new bug has been found. I've filed it here: https://github.com/cue-lang/cue/issues/3325

mvdan commented 6 days ago

Thank you @alecholmez - it turns out @nyarly's bug that @rogpeppe filed was a duplicate of https://github.com/cue-lang/cue/issues/3062, which had already been fixed in master in early June, so it makes sense that your panic here was also solved the same way. Given that you opened https://github.com/cue-lang/cue/issues/3325, I think we can close this one now as another duplicate. Thanks!