Skip to content

std: simplify the miri bypass of the stack overflow detection logic - #163743

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
joboet:miri_bypass_stack_overflow
Oct 24, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
joboet:miri_bypass_stack_overflow

Conversation

@joboet

@joboet joboet commented Oct 4, 2026

Copy link
Copy Markdown
Member

This is split out from #162296. Using cfg!(miri) instead of compile-time configuration avoids creating warnings about unused imports. And by creating a init function in the main module, there's space to put further shared logic.

This would disable the stack overflow logic when running Cygwin targets under miri, but Cygwin isn't supported by miri anyhow.

@rustbot

rustbot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

@rustbot rustbot added O-unix Operating system: Unix-like 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 Oct 4, 2026
@rustbot

rustbot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from ChrisDenton, Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey

@rust-log-analyzer

This comment has been minimized.

@joboet
joboet force-pushed the miri_bypass_stack_overflow branch from bd5d0fe to a429208 Compare October 4, 2026 11:16
Comment on lines +71 to 73
if cfg!(miri) {
return;
}

@RalfJung RalfJung Oct 4, 2026 •

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.

Isn't the existing handler already required to be sound on a null pointer? Why does Miri need a special check?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

drop_handler unconditionally accesses the thread information BTreeMap, which means there is some extra synchronisation – enough to make some miri tests fail.

make_handler(false)
if cfg!(miri) {
return Handler::null();
}

@RalfJung RalfJung Oct 4, 2026 •

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.

A comment similar to above would be good.

View changes since the review

@joboet
joboet force-pushed the miri_bypass_stack_overflow branch from a429208 to cdd050c Compare October 11, 2026 09:26

@RalfJung RalfJung 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.

Thanks! LGTM. But I don't really understand this code so probably a t-libs person should look at this as well.

View changes since this review

@ChrisDenton

Copy link
Copy Markdown
Member

Looks good to me too

r? ChrisDenton
@bors r+

@rust-bors

rust-bors Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit cdd050c has been approved by ChrisDenton

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 23, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 23, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #163743 (std: simplify the miri bypass of the stack overflow detection logic)
 - #164474 (core: implement `char::is_xid_{start|continue}`)
 - #164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`)
 - #164739 (Use cfi_encoding instead of name in abi checking in miri)
 - #162927 (stabilize ptr_cast_slice)
 - #163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers)
 - #164261 (Simplify MSYS check in is_terminal on Windows)
 - #164698 (Remove FCP from libs tracking checklist)
 - #164810 (Don't prioritize issues that require internal features)
@rust-bors
rust-bors Bot merged commit bf8930f into rust-lang:main Oct 24, 2026
14 checks passed
rust-bors Bot pushed a commit that referenced this pull request Oct 24, 2026
Rollup merge of #163743 - joboet:miri_bypass_stack_overflow, r=ChrisDenton

std: simplify the miri bypass of the stack overflow detection logic

This is split out from #162296. Using `cfg!(miri)` instead of compile-time configuration avoids creating warnings about unused imports. And by creating a `init` function in the main module, there's space to put further shared logic.

This would disable the stack overflow logic when running Cygwin targets under miri, but Cygwin isn't supported by miri anyhow.
@rustbot rustbot added this to the 1.101.0 milestone Oct 24, 2026
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Oct 24, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#163743 (std: simplify the miri bypass of the stack overflow detection logic)
 - rust-lang/rust#164474 (core: implement `char::is_xid_{start|continue}`)
 - rust-lang/rust#164643 (Const-stabilize `{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque)::{len, is_empty}`)
 - rust-lang/rust#164739 (Use cfi_encoding instead of name in abi checking in miri)
 - rust-lang/rust#162927 (stabilize ptr_cast_slice)
 - rust-lang/rust#163372 (Restrict `PartialEq` and `PartialOrd` documentation to thin pointers)
 - rust-lang/rust#164261 (Simplify MSYS check in is_terminal on Windows)
 - rust-lang/rust#164698 (Remove FCP from libs tracking checklist)
 - rust-lang/rust#164810 (Don't prioritize issues that require internal features)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like 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.

6 participants