Commit e1831b2
fix(borrow): round-3 hardening — ref-count Slice-B reassign + union reassigned-local summary
A third adversarial-verification pass on the #554 return-borrow work surfaced
two more reachable holes (and confirmed the interprocedural fixpoint is robust:
60-level wrapper chains, mutual recursion, and 3-cycles all terminate in ms and
summarise correctly).
- Slice-B `&` reassign (a PRE-EXISTING soundness bug, exposed by the #554 (c)
block being more correct): `r = &b` ended the binder's old loan
UNCONDITIONALLY, so `let r2 = r; r = &b; consume(a); *r2` dropped the borrow
`r2` still aliased and accepted a use-after-move. Now ref-counted by b_id
(mirroring the (c) block and expire_dead_ref_bindings), so an aliased loan
survives the reassign. The `&mut` variant (exclusive aliasing) is caught too.
- Reassigned-local summary: the summary walker did not update a reassigned
ref-local's origins, so `let mut t = pick(y); t = pick(x); return t`
summarised the stale {y}. It now UNIONs origins on reassignment
(conservative, flow-insensitive), summarising {x,y}.
Two low-severity residuals are documented in-code (Polonius #553 closes them):
a summary that cannot bootstrap an origin for a base-case-less divergent
recursion (unreachable — the function never returns), and a loop-body reassign
to an outer borrow (&-symmetric, predates #554).
Full suite 397/397 green; +2 regression fixtures (alias-survives-reassign,
reassigned-local-summary).
Refs #554.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 20b2131 commit e1831b2
4 files changed
Lines changed: 145 additions & 5 deletions
File tree
- lib
- test
- e2e/fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
365 | 380 | | |
366 | 381 | | |
367 | 382 | | |
| |||
1793 | 1808 | | |
1794 | 1809 | | |
1795 | 1810 | | |
1796 | | - | |
1797 | | - | |
1798 | | - | |
1799 | | - | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
1800 | 1827 | | |
1801 | 1828 | | |
1802 | 1829 | | |
| |||
2111 | 2138 | | |
2112 | 2139 | | |
2113 | 2140 | | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
2114 | 2147 | | |
2115 | 2148 | | |
2116 | 2149 | | |
| |||
2133 | 2166 | | |
2134 | 2167 | | |
2135 | 2168 | | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
2136 | 2183 | | |
2137 | 2184 | | |
2138 | 2185 | | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5277 | 5277 | | |
5278 | 5278 | | |
5279 | 5279 | | |
| 5280 | + | |
| 5281 | + | |
| 5282 | + | |
| 5283 | + | |
| 5284 | + | |
| 5285 | + | |
| 5286 | + | |
| 5287 | + | |
| 5288 | + | |
| 5289 | + | |
| 5290 | + | |
| 5291 | + | |
| 5292 | + | |
| 5293 | + | |
| 5294 | + | |
| 5295 | + | |
| 5296 | + | |
| 5297 | + | |
| 5298 | + | |
| 5299 | + | |
| 5300 | + | |
| 5301 | + | |
| 5302 | + | |
| 5303 | + | |
| 5304 | + | |
| 5305 | + | |
| 5306 | + | |
5280 | 5307 | | |
5281 | 5308 | | |
5282 | 5309 | | |
| |||
5352 | 5379 | | |
5353 | 5380 | | |
5354 | 5381 | | |
| 5382 | + | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
5355 | 5386 | | |
5356 | 5387 | | |
5357 | 5388 | | |
| |||
0 commit comments