Guard pages are disabled on musl.

d61b879
Opened by Brian Anderson at 2022-06-01 21:25:22

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.

  1. I've found this issue again through https://github.com/rust-lang/rust/pull/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.

    Alex Crichton at 2017-07-03 17:08:06

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

    Squirrel at 2018-06-12 05:06:49

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

    Mateusz MikuĊ‚a at 2019-01-10 20:42:51