Skip to content

Commit

Permalink
internal/core/adt: fix 2235
Browse files Browse the repository at this point in the history
The current implementation finalizes vertices too
aggressively. This may result in conjuncts being
missed. The new notify mechanism may then end up
adding conjuncts to already-finalized vertices.

The fix for this is planned in v0.6. The current
implementation is already a lot more robust than
it way. However, although it problably fixes more
than that it breaks, it may break things that were
previously working.

This change more aggresively early evaluates
conjuncts to prevent them from being missed if a
node is in finalization mode. This fix most likely
will not cover all cases, but hopefully enough to
hold over until v0.6.

Fixes #2235

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ia86e9efecde0225caf0d700bf797a3b2e6cfb2f1
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549247
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Feb 1, 2023
1 parent 2e70ac7 commit 3c8f0ad
Show file tree
Hide file tree
Showing 86 changed files with 200 additions and 203 deletions.
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/018_self-reference_cycles.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Leaks: 0
Freed: 6
Reused: 2
Allocs: 4
Retain: 7
Retain: 11

Unifications: 6
Conjuncts: 22
Conjuncts: 26
Disjuncts: 7
-- out/eval --
(struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/basicrewrite/aliases/aliases.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Leaks: 0
Freed: 9
Reused: 4
Allocs: 5
Retain: 2
Retain: 3

Unifications: 9
Conjuncts: 15
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/benchmarks/issue2176.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Leaks: 218
Freed: 5799
Reused: 5795
Allocs: 222
Retain: 1077
Retain: 1915

Unifications: 6009
Conjuncts: 14515
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/builtins/incomplete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ Leaks: 7
Freed: 122
Reused: 117
Allocs: 12
Retain: 32
Retain: 54

Unifications: 109
Conjuncts: 267
Disjuncts: 150
Disjuncts: 156
-- out/eval --
Errors:
badListType.decimal: cannot use 2 (type int) as list in argument 1 to list.Max:
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/compile/scope.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ Leaks: 2
Freed: 50
Reused: 47
Allocs: 5
Retain: 7
Retain: 8

Unifications: 52
Conjuncts: 107
Disjuncts: 55
Disjuncts: 56
-- out/eval --
Errors:
schema.next: structural cycle
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/015_list_comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ Leaks: 0
Freed: 19
Reused: 11
Allocs: 8
Retain: 5
Retain: 14

Unifications: 19
Conjuncts: 39
Disjuncts: 20
Disjuncts: 23
-- out/eval --
(struct){
a: (#list){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ Leaks: 3
Freed: 7
Reused: 2
Allocs: 8
Retain: 3
Retain: 8

Unifications: 8
Conjuncts: 11
Disjuncts: 10
Disjuncts: 13
-- out/eval --
(struct){
x: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/checkdefined.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ Leaks: 11
Freed: 81
Reused: 77
Allocs: 15
Retain: 22
Retain: 24

Unifications: 92
Conjuncts: 116
Disjuncts: 96
Disjuncts: 97
-- out/eval --
(struct){
xc: (#struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/closed.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ Leaks: 2
Freed: 70
Reused: 63
Allocs: 9
Retain: 10
Retain: 15

Unifications: 58
Conjuncts: 104
Disjuncts: 77
Disjuncts: 81
-- out/eval --
Errors:
disallowed.vErr.d: field not allowed:
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/for.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Leaks: 4
Freed: 16
Reused: 12
Allocs: 8
Retain: 9
Retain: 11

Unifications: 20
Conjuncts: 20
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/iferror.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ Leaks: 0
Freed: 43
Reused: 35
Allocs: 8
Retain: 15
Retain: 22

Unifications: 33
Conjuncts: 68
Disjuncts: 53
Disjuncts: 60
-- out/eval --
Errors:
issue1972.err1: conflicting values [] and {someCondition:_,patchs:[...{}],patchs,if someCondition {patchs:_}} (mismatched types list and struct):
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/issue1732.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ Leaks: 4
Freed: 118
Reused: 105
Allocs: 17
Retain: 10
Retain: 19

Unifications: 112
Conjuncts: 249
Disjuncts: 126
Disjuncts: 133
-- out/eval --
(struct){
networkingv1: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/issue2171.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Leaks: 0
Freed: 3
Reused: 0
Allocs: 3
Retain: 1
Retain: 2

Unifications: 3
Conjuncts: 5
Disjuncts: 4
Disjuncts: 5
-- out/eval --
(struct){
do: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/issue287.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Leaks: 0
Freed: 5
Reused: 1
Allocs: 4
Retain: 1
Retain: 2

Unifications: 5
Conjuncts: 8
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/issue837.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ Leaks: 16
Freed: 117
Reused: 108
Allocs: 25
Retain: 68
Retain: 123

Unifications: 107
Conjuncts: 295
Disjuncts: 185
Disjuncts: 240
-- out/eval --
Errors:
#Configure.service.description.role: undefined field: role:
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/issue843.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Leaks: 9
Freed: 55
Reused: 41
Allocs: 23
Retain: 16
Retain: 20

Unifications: 52
Conjuncts: 120
Disjuncts: 65
Disjuncts: 66
-- out/eval --
(struct){
#d1: (#struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/nested.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Leaks: 0
Freed: 45
Reused: 26
Allocs: 19
Retain: 13
Retain: 36

Unifications: 35
Conjuncts: 96
Disjuncts: 57
Disjuncts: 78
-- out/eval --
(struct){
service: (struct){
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/comprehensions/nested2.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Leaks: 0
Freed: 43
Reused: 38
Allocs: 5
Retain: 5
Retain: 6

Unifications: 43
Conjuncts: 78
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ Leaks: 17
Freed: 392
Reused: 386
Allocs: 23
Retain: 70
Retain: 134

Unifications: 395
Conjuncts: 646
Disjuncts: 440
Disjuncts: 483
-- out/eval --
Errors:
embed.fail1.p: field not allowed:
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/015_reference_across_tuples_and_back.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Leaks: 0
Freed: 7
Reused: 1
Allocs: 6
Retain: 3
Retain: 8

Unifications: 7
Conjuncts: 13
Disjuncts: 9
Disjuncts: 12
-- out/eval --
(struct){
a: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/023_reentrance.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Leaks: 16
Freed: 180
Reused: 169
Allocs: 27
Retain: 105
Retain: 224

Unifications: 196
Conjuncts: 464
Disjuncts: 276
Disjuncts: 292
-- out/eval --
Errors:
structural cycle:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ Leaks: 0
Freed: 48
Reused: 39
Allocs: 9
Retain: 4
Retain: 12

Unifications: 24
Conjuncts: 71
Conjuncts: 72
Disjuncts: 46
-- out/eval --
(struct){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Leaks: 5
Freed: 47
Reused: 40
Allocs: 12
Retain: 27
Retain: 36

Unifications: 31
Conjuncts: 133
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Leaks: 6
Freed: 38
Reused: 34
Allocs: 10
Retain: 29
Retain: 38

Unifications: 27
Conjuncts: 93
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/builtins.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ Leaks: 0
Freed: 37
Reused: 30
Allocs: 7
Retain: 26
Retain: 34

Unifications: 37
Conjuncts: 61
Disjuncts: 57
Disjuncts: 61
-- out/eval --
(struct){
builtinCyclePerm0: (struct){
Expand Down
6 changes: 3 additions & 3 deletions cue/testdata/cycle/chain.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ Leaks: 123
Freed: 4431
Reused: 4412
Allocs: 142
Retain: 689
Retain: 720

Unifications: 1799
Conjuncts: 7509
Disjuncts: 5078
Conjuncts: 7517
Disjuncts: 5086
-- out/eval --
(struct){
chain: (struct){
Expand Down
6 changes: 3 additions & 3 deletions cue/testdata/cycle/compbottom.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ Leaks: 0
Freed: 85
Reused: 73
Allocs: 12
Retain: 64
Retain: 200

Unifications: 85
Conjuncts: 149
Disjuncts: 111
Conjuncts: 152
Disjuncts: 194
-- out/eval --
(struct){
simple: (struct){
Expand Down
4 changes: 2 additions & 2 deletions cue/testdata/cycle/compbottom2.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ Leaks: 3
Freed: 141
Reused: 132
Allocs: 12
Retain: 35
Retain: 66

Unifications: 144
Conjuncts: 159
Disjuncts: 163
Disjuncts: 186
-- out/eval --
(struct){
self: (struct){
Expand Down
6 changes: 3 additions & 3 deletions cue/testdata/cycle/compbottomnofinal.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ Leaks: 16
Freed: 95
Reused: 84
Allocs: 27
Retain: 129
Retain: 292

Unifications: 111
Conjuncts: 194
Disjuncts: 130
Conjuncts: 227
Disjuncts: 206
-- out/eval --
(struct){
minimal: (struct){
Expand Down
6 changes: 3 additions & 3 deletions cue/testdata/cycle/comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ Leaks: 48
Freed: 1268
Reused: 1256
Allocs: 60
Retain: 125
Retain: 198

Unifications: 828
Conjuncts: 2521
Disjuncts: 1377
Conjuncts: 2522
Disjuncts: 1443
-- out/eval --
Errors:
selfReferential.insertionError.A: field foo3 not allowed by earlier comprehension or reference cycle
Expand Down
2 changes: 1 addition & 1 deletion cue/testdata/cycle/evaluate.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Leaks: 67
Freed: 94
Reused: 90
Allocs: 71
Retain: 119
Retain: 137

Unifications: 149
Conjuncts: 291
Expand Down
Loading

0 comments on commit 3c8f0ad

Please sign in to comment.