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

Guard pages are disabled on musl. #31506

Open
Tracked by #49355
brson opened this issue Feb 9, 2016 · 3 comments
Open
Tracked by #49355

Guard pages are disabled on musl. #31506

brson opened this issue Feb 9, 2016 · 3 comments
Labels
A-stack-probe Area: Stack probing and guard pages C-bug Category: This is a bug. O-musl Target: The musl libc

Comments

@brson
Copy link
Contributor

brson commented Feb 9, 2016

In #30629 I disabled guard pages on musl. I did this because one of the pthread calls (I've forgotten which) was segfaulting during runtime initialization on i686-unknown-linux-musl, with my local build of musl, and I just wanted it working.

It should at least be on for x86_64 where it's known to work on the bots.

@brson brson added I-wrong O-linux Operating system: Linux labels Feb 9, 2016
@alexcrichton alexcrichton added the O-musl Target: The musl libc label Jul 3, 2017
@alexcrichton
Copy link
Member

I've found this issue again through #42816 as it bounced. I poked around in the source code for musl and it looks like guard pages are not disabled. What it looks like is that guard page detection in libstd is disabled.

Our detection of the guard page relies on pthread_getattr_np which on musl is implemented to only fill out some fields, specifically not the fields related to the guard size.

I believe the consequence of this is that on musl you don't get a pretty "you overflowed your stack" error message, you just get a scary segfault. Technically though I believe guard pages are indeed enabled and we'll guarantee segfaults on stack overflow.

@gilescope
Copy link
Contributor

gilescope commented Jun 12, 2018

Looking at the musl source, musl is now specifying the guard size as of the feb 2018 commit:
https://git.musl-libc.org/cgit/musl/commit/src?id=7c709f2d4f9872d1b445f760b0e68da89e256b9e
and I've checked that it picked up in mainline musl v1.1.19 and that looks like it will be in AlpineLinux 3.8 once it comes out...

@mati865
Copy link
Contributor

mati865 commented Jan 10, 2019

I tried enabling it in https://github.com/rust-lang/rust/blob/6ecad338381cc3b8d56e2df22e5971a598eddd6c/src/libstd/sys/unix/thread.rs but overflow tests fail the same way as before.
At least i686 build didn't crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stack-probe Area: Stack probing and guard pages C-bug Category: This is a bug. O-musl Target: The musl libc
Projects
None yet
Development

No branches or pull requests

7 participants