Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack overflow detection on FreeBSD 11.1+ #83771

Merged
merged 1 commit into from
Apr 2, 2021

Conversation

asomers
Copy link
Contributor

@asomers asomers commented Apr 2, 2021

Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default. And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page. The best solution is
to just use the OS's guard page.

Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default.  And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page.  The best solution is
to just use the OS's guard page.
@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 2, 2021
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

As far as I can tell, you wrote this code originally (#32726), so that's good enough for me to approve without particular scrutiny.

Mentioning @cuviper (based on #47912) in case you get a chance to look this over as a sanity check.

@dtolnay
Copy link
Member

dtolnay commented Apr 2, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Apr 2, 2021

📌 Commit ca14abb has been approved by dtolnay

@bors bors 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 Apr 2, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Apr 2, 2021
…tolnay

Fix stack overflow detection on FreeBSD 11.1+

Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default.  And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page.  The best solution is
to just use the OS's guard page.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Apr 2, 2021
…tolnay

Fix stack overflow detection on FreeBSD 11.1+

Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default.  And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page.  The best solution is
to just use the OS's guard page.
@asomers
Copy link
Contributor Author

asomers commented Apr 2, 2021

Yeah I did. But I didn't do a great job because:

  1. I didn't understand the issue very well
  2. Back then (FreeBSD 10.3) there was no default guard page, and
  3. I probably never tested with a multithreaded program.

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#83065 (Rework `std::sys::windows::alloc`)
 - rust-lang#83478 (rustdoc: Add unstable option to only emit shared/crate-specific files)
 - rust-lang#83629 (Fix double-drop in `Vec::from_iter(vec.into_iter())` specialization when items drop during panic)
 - rust-lang#83673 (give full path of constraint in suggest_constraining_type_param)
 - rust-lang#83755 (Simplify coverage tests)
 - rust-lang#83757 (2229: Support migration via rustfix)
 - rust-lang#83771 (Fix stack overflow detection on FreeBSD 11.1+)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@nagisa
Copy link
Member

nagisa commented Apr 2, 2021

Huh, does FreeBSD really allocate a guard page for thread stacks as well? Surprising, but also very sensible.

@cuviper
Copy link
Member

cuviper commented Apr 2, 2021

Mentioning @cuviper (based on #47912) in case you get a chance to look this over as a sanity check.

LGTM! My prior contribution was to maintain the existing effect on FreeBSD, adding that FIXME because it seemed weird. I'm happy to let an actual user verify what does or does not work. So congrats, @asomers, you get to be our local expert! 🙂

@bors bors merged commit cb7133f into rust-lang:master Apr 2, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 2, 2021
@asomers
Copy link
Contributor Author

asomers commented Apr 2, 2021

@asomers asomers deleted the stack_overflow_freebsd branch April 2, 2021 22:48
@asomers asomers mentioned this pull request Apr 7, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants