Repository navigation
fix: panic instead of wrapping counts in sharecommon_quick_fn - #15289
Merged
Merged
Conversation
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. `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]>
Member
Author
|
!bench |
|
Benchmark results for 6e3a708 against 3baf820 are in. No significant results found. @Kha
No significant changes detected. |
Kha
marked this pull request as ready for review
September 24, 2026 12:38
Kha
enabled auto-merge
September 24, 2026 12:46
Use `__builtin_add_overflow` only under GCC and clang, as `lean.h` does, with an explicit `INT_MAX` test otherwise. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-releases/v4.34.0 releases/v4.34.0
# Navigate to the new working tree
cd .worktrees/backport-releases/v4.34.0
# Create a new branch
git switch --create backport-15289-to-releases/v4.34.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1a63affc1b788fa3b9823ef3ee9805f03501e9b8
# Push it to GitHub
git push --set-upstream origin backport-15289-to-releases/v4.34.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-releases/v4.34.0Then, create a pull request where the |
Kha
added a commit
that referenced
this pull request
Sep 24, 2026
…`sharecommon_quick_fn` (#15303) Backport 1a63aff from #15289. Co-authored-by: Sebastian Ullrich <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-releases/v4.34.0 releases/v4.34.0
# Navigate to the new working tree
cd .worktrees/backport-releases/v4.34.0
# Create a new branch
git switch --create backport-15289-to-releases/v4.34.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1a63affc1b788fa3b9823ef3ee9805f03501e9b8
# Push it to GitHub
git push --set-upstream origin backport-15289-to-releases/v4.34.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-releases/v4.34.0Then, create a pull request where the |
Kha
added a commit
that referenced
this pull request
Sep 24, 2026
…`sharecommon_quick_fn` (#15307) Backport 1a63aff from #15289. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes maximal sharing, including the kernel's sharing of every theorem it checks, panic when a shared subterm gains more than
INT_MAXreferences, instead of eventually freeing the subterm while it is still referenced. On inputs north of 100GB, the possibility of triggering undefined behavior in the official kernel this way, which could be extended into a proof of False, could not 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_fntakes references to the objects it creates with a raw increment, skipping the sign test oflean_inc_refbecause these objects are single-threaded. PastINT_MAXthat 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.