1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
//! Synthetic diagnostic harnesses for isolating BTreeMap/HashMap drop-glue issues.
//!
//! These theories use local enum types (no workspace dependencies) to pinpoint
//! whether enum union drop-glue causes unbounded CBMC unwinding when one variant
//! holds a BTreeMap but a *different* variant is constructed.
//!
//! Theories:
//! - BC: 2-variant enum, one arm has `BTreeMap`, construct the *other* arm → hang?
//! - BD: Same but `Box<BTreeMap>` in the BTree arm → does boxing fix it?
//! - BE: 2-variant enum, one arm has `HashMap`, construct the other arm → hang?
//! - BF: Same but `Box<HashMap>` → does boxing fix HashMap too?
use ;
// ── Theory BC ─────────────────────────────────────────────────────────────────
// 2-variant enum: variant A holds a BTreeMap, variant B holds a plain u32.
// We construct and drop B only — B has no BTreeMap.
//
// If this hangs: CBMC's static reachability pulls in A's drop-glue (BTree
// traversal) even when B is the live variant → union drop-glue is the culprit.
// If this passes: the problem is specific to the size/shape of ArchivePanelState.
// ── Theory BD ─────────────────────────────────────────────────────────────────
// Same as BC but variant A holds `Box<BTreeMap<String, f32>>`.
//
// If BC hangs but BD passes: boxing the BTree field cuts the reachable drop path
// (pointer dereference can be pruned; tree traversal cannot).
// ── Theory BE ─────────────────────────────────────────────────────────────────
// Same structure but with HashMap instead of BTreeMap.
// HashMap::new() is fine (no getrandom in Kani); question is drop-glue.
// ── Theory BF ─────────────────────────────────────────────────────────────────
// HashMap behind Box — does boxing fix HashMap drop-glue too?
// ── Theory BG ─────────────────────────────────────────────────────────────────
// Scale test: 20-variant enum where only variant A0 has a BTreeMap, all others
// hold a plain u32. Construct variant A19.
//
// BC (2-variant) passed in 0.21s. If BG (20-variant) hangs, the problem is
// CBMC's per-variant drop-path analysis scaling with the number of variants.
// ── Theory BH ─────────────────────────────────────────────────────────────────
// Recursive type in one arm: variant A holds a locally-recursive enum, variant
// B holds a u32. Construct B.
//
// serde_json::Value and DbValue::Json are recursive types present in
// ArchivePanelState::DataGrid. If CBMC can't bound the drop of a recursive
// type even when we never construct it, this hangs.
// ── Theory BI ─────────────────────────────────────────────────────────────────
// Same as BG (20-variant, BTree in A0) but the constructed arm A1 uses a
// SYMBOLIC value via kani::any() instead of a concrete 42.
//
// Result: PASS 0.13s — symbolic primitive + BTree in other arm is fine.
// ─────────────────────────────────────────────────────────────────────────────
// Ladder: incrementally approach AZ to find exactly what causes the hang.
//
// AZ: ArchivePanelState::ConnectionEdit { profile: ConnectionProfile::kani_depth0(),
// display_mode: ... } → HANGS
//
// Known passing: BC (2-var, BTree dead, u32 live concrete)
// BI (20-var, BTree dead, u32 live symbolic)
//
// We flip one variable per rung:
// - What is in the LIVE arm (constructed variant)?
// - What is in the DEAD arm (the non-constructed variant with complex drop)?
// ─────────────────────────────────────────────────────────────────────────────
// ── Rung 1 / Theory BJ ───────────────────────────────────────────────────────
// Live arm: String::new() — heap allocation, non-trivial drop but bounded.
// Dead arm: BTreeMap<String,f32>
// Question: does a String in the live arm matter?
// ── Rung 2 / Theory BK ───────────────────────────────────────────────────────
// Live arm: bool + u16 + String — mimics a minimal ConnectionProfile
// Dead arm: BTreeMap<String,f32>
// Question: does a multi-field live arm (some symbolic) + BTree dead matter?
// ── Rung 3 / Theory BL ───────────────────────────────────────────────────────
// Live arm: concrete u32
// Dead arm: Vec<String> — heap collection whose drop iterates over elements
// Question: does Vec<T-with-drop> in the dead arm (vs BTree) cause a hang?
// ── Rung 4 / Theory BM ───────────────────────────────────────────────────────
// Live arm: symbolic kani::any::<u32>()
// Dead arm: Vec<String>
// Question: does symbolic live arm + Vec<String> dead matter?
// ── Rung 5 / Theory BN ───────────────────────────────────────────────────────
// Live arm: bool + u16 + String (ConnectionProfile-like, some symbolic)
// Dead arm: Vec<String>
// Question: ConnectionProfile-like complexity in live arm + Vec dead — hang?
// ─────────────────────────────────────────────────────────────────────────────
// Ladder 2: isolate the ConnectionEdit / ConnectionProfile hang
//
// BG (elicit_proofs): SqlEditor{ 2 Option fields } PASSES
// BE/BF (elicit_proofs): ConnectionEdit{ ConnectionProfile{ 7 Option<String> } } HANGS
//
// Hypothesis: 7 Option<String> fields cause the hang, either because of count
// or because of nested-struct wrapping. Theories below flip each variable.
// ─────────────────────────────────────────────────────────────────────────────
// ── Theory BO ─────────────────────────────────────────────────────────────────
// 2-variant enum; LIVE arm has 7 Option<String> as DIRECT fields (no wrapper).
// Dead arm is a plain u32 (trivial drop).
// Pass → the count alone isn't the trigger; wrapping matters.
// Hang → 7 Option<String> direct fields is itself enough to cause the hang.
// ── Theory BP ─────────────────────────────────────────────────────────────────
// 2-variant enum; LIVE arm has a NESTED struct with 7 Option<String> fields.
// This directly mirrors ConnectionProfile inside ConnectionEdit.
// Dead arm is a plain u32 (trivial drop).
// Pass → nesting isn't the trigger.
// Hang → wrapping in a nested struct is the trigger (vs BO's direct fields).
// ── Theory BQ ─────────────────────────────────────────────────────────────────
// SAME as BP but dead arm has BTreeMap (like ErdView in ArchivePanelState has
// Option<ErdLayout> which contains a BTreeMap).
// RESULT: HANGS — BTree dead arm + complex live arm triggers unbounded loop.
// #[kani::proof]
// fn theory_bq_nested_profile_btree_dead() { ... }
// ── Theory BR ─────────────────────────────────────────────────────────────────
// Same as BQ but dead arm holds Box<BTreeMap> instead of BTreeMap directly.
// RESULT: HANGS — boxing the dead-arm BTree alone does not fix the interaction.
// #[kani::proof]
// fn theory_br_nested_profile_boxed_btree_dead() { ... }
// ── Theory BS ─────────────────────────────────────────────────────────────────
// Same setup as BQ (MockProfile live, BTree dead) but the live arm BOXES
// MockProfile, reducing the union footprint of the live arm to just a pointer.
//
// If this passes: boxing the LIVE arm's large struct is the fix.
// → In ArchivePanelState, Box ConnectionProfile inside ConnectionEdit.
// If this hangs: we need to box both arms or use a different approach.