Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zakrad:fix-136797-rc-arc-capacity-overflow
Aug 1, 2026
Merged

Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>#159864
rust-bors[bot] merged 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
Contributor

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

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 024bd5e has been approved by JohnTitor

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
…overflow, r=JohnTitor

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

Fixes rust-lang#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.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
…overflow, r=JohnTitor

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

Fixes rust-lang#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.
rust-bors Bot pushed a commit that referenced this pull request Aug 1, 2026
Rollup of 14 pull requests

Successful merges:

 - #159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
 - #159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
 - #160079 (make atomic operations const)
 - #160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
 - #160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
 - #160210 (Remove an outdated FIXME)
 - #160282 (Improve diagnostic for patterns in function pointer types)
 - #157928 (Eagerly fetch typeck results when linting)
 - #159672 (Improve suggestions when multiples tuples implement the same trait)
 - #159861 (Add documentation for the `non_exhaustive` attribute)
 - #159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
 - #159998 (Align expect messages with guidance)
 - #160145 (Expand checks for register_tool)
 - #160307 (Update `minifier` version to `0.4.0`)
@rust-bors
rust-bors Bot merged commit 95bb796 into rust-lang:main Aug 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 1, 2026
rust-timer added a commit that referenced this pull request Aug 1, 2026
Rollup merge of #159864 - zakrad:fix-136797-rc-arc-capacity-overflow, r=JohnTitor

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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