Skip to content

[Backport releases/v4.34.0] fix: panic instead of wrapping counts in sharecommon_quick_fn - #15307

Merged
Kha merged 1 commit into
releases/v4.34.0from
backport-15289-to-releases/v4.34.0
Sep 24, 2026
Merged

Kha merged 1 commit into
releases/v4.34.0from
backport-15289-to-releases/v4.34.0

Conversation

@Kha

@Kha Kha commented Sep 24, 2026

Copy link
Copy Markdown
Member

Backport 1a63aff from #15289.

This PR makes maximal sharing, including the kernel's sharing of every
theorem it checks, panic when a shared subterm gains more than `INT_MAX`
references, instead of eventually freeing the subterm while it is still
referenced. On inputs north of 100GB, the possibility of triggering
undefined behavior this way, which could be extended into a proof of
False, could be excluded. Other kernels such as nanoda or con-leche not
based on the Lean runtime or not making use of this specific function
were not affected.

`sharecommon_quick_fn` takes references to the objects it creates with a
raw increment, skipping the sign test of `lean_inc_ref` because these
objects are single-threaded. Past `INT_MAX` that increment wrapped the
count into the sticky range, and further cache hits walked it back out
of that range. The increment now checks its overflow flag and panics, so
the hit path keeps its single add plus a branch that is never taken.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit 1a63aff)
@Kha
Kha merged commit 846ad6c into releases/v4.34.0 Sep 24, 2026
9 of 10 checks passed
hyperpolymath added a commit to hyperpolymath/marches that referenced this pull request Oct 14, 2026
Follow-up to the CodeRabbit review on #36 (thread
on `lean-toolchain`, flagged Major / security): pin v4.34.1, the patched
release of the 4.34 line.

## Verified against the primary source, not the bot's summary

`git log v4.34.0..v4.34.1` in leanprover/lean4 shows:

- three runtime reference-count fixes:
  - leanprover/lean4#15241: preserve sticky counts in deletion cascades
- leanprover/lean4#15288: mark the children of objects whose
single-threaded count overflowed
- leanprover/lean4#15307: panic instead of wrapping counts in
`sharecommon_quick_fn`
- a `BitVec.ofNatClamp` backport
- `chore: prepare release` (`5045d00`, 2026-09-24)

marches checks only its own proofs, not untrusted input, so the
practical risk was low. Still, this is a same-line patch bump, it costs
nothing, and it keeps the estate's 4.34 soundness floor on the patched
build.

## Change

- `lean-toolchain`: `v4.34.0` → `v4.34.1`
- `README.adoc`: the two version mentions
- `STATE.adoc`: a dated entry. The v4.34.0 results are now marked
historical.

No source change.

## Gates (v4.34.1)

```
$ rm -rf .lake && lake build
Build completed successfully (15 jobs).
$ grep -rnw sorry Marches/ Marches.lean ; echo $?
1
$ lake env lean Marches/BadGadget.lean
[(false, false), (true, true), (false, false), (true, true)]
```

## Note on the stack

#38 (rung-3 docs) is independent of this PR. Both
add a `STATE.adoc` entry at the top, so whichever merges second will
need a trivial merge, which I'll handle.

CI here shows the same two pre-existing reds as `main` (`CI`
`startup_failure` from `actions.lock` drift, and `estate-audit` from the
cicd-suite pipefail bug). Both are diagnosed in
#37.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VTeVWDEJgdYKsUNr4uhnXX

---
_Generated by [Claude
Code](https://claude.ai/code/session_01VTeVWDEJgdYKsUNr4uhnXX)_

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant