Repository navigation
[Backport releases/v4.35.0] fix: panic instead of wrapping counts in sharecommon_quick_fn - #15303
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. 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)
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.
Backport 1a63aff from #15289.