Skip to content

Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>#159864

Open
zakrad wants to merge 1 commit into
rust-lang:mainfrom
zakrad:fix-136797-rc-arc-capacity-overflow
Open

Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>#159864
zakrad wants to merge 1 commit into
rust-lang:mainfrom
zakrad:fix-136797-rc-arc-capacity-overflow

Conversation

@zakrad

@zakrad zakrad commented Jul 24, 2026

Copy link
Copy Markdown

Fixes #136797.

Building an Rc<[T]>/Arc<[T]> whose header + payload layout exceeds
isize::MAX unwrapped a LayoutError and panicked with "called
Result::unwrap() on an Err value: LayoutError". Vec and Box report
"capacity overflow" here; this makes Rc/Arc do the same.

Used an inline panic!("capacity overflow") rather than raw_vec's
capacity_overflow(), since that helper is cfg'd out under
no_global_oom_handling while these two layout fns still compile there.

Constructing an Rc<[T]> or Arc<[T]> whose header + payload layout exceeds
isize::MAX unwrapped a LayoutError, panicking with the opaque "called
`Result::unwrap()` on an `Err` value: LayoutError". Match Vec and Box by
reporting "capacity overflow" instead, and add regression tests.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 24, 2026
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @JohnTitor (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from 6 candidates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unwrapping LayoutError for overflowed Rc<[T]>/Arc<[T]> capacity

3 participants