Skip to content

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

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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 20b1ee5 into releases/v4.35.0 Sep 24, 2026
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