Skip to content

std: move guard page logic to separate file - #166388

Open
joboet wants to merge 2 commits into
rust-lang:mainfrom
joboet:guard_page_sep
Open

joboet wants to merge 2 commits into
rust-lang:mainfrom
joboet:guard_page_sep

Conversation

@joboet

@joboet joboet commented Nov 23, 2026

Copy link
Copy Markdown
Member

Setting up a guard page on the main thread is different from setting up a signal handler to report stack overflows. It cannot be skipped under panic = "immediate-abort" and might be necessary even if the system does not support signal handling (cf. #125390).

In preparation for properly separating guard page setup and finding, this PR moves the guard page logic to a different module than handler_signal. This necessitates passing the system's page size through an argument in a few places since the static where the value returned by sysconf is cached is no longer reachable, see the second commit for that adjustment (and the import adjustment).

@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 Nov 23, 2026
@rustbot

rustbot commented Nov 23, 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 38 candidates
  • Random selection from JohnTitor, Mark-Simulacrum

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

Maybe a try build is useful here to find out all the missing items.

View changes since this review

// SAFETY: this is always safe to call.
let stackaddr = if unsafe { libc::pthread_main_np() } == 1 {
// main thread
stack_ptr.addr() - current_stack.ss_size + PAGE_SIZE.load(Ordering::Relaxed)

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.

PAGE_SIZE is currently only on handler_signal.rs so this could fail to build.

This branch has not been deployed

No deployments
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-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.

3 participants