Skip to content

Guard pages are disabled on musl. #31506

@brson

Description

@brson
Contributor

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.

Activity

alexcrichton

alexcrichton commented on Jul 3, 2017

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

added
C-bugCategory: This is a bug.
and removed on Jul 24, 2017
gilescope

gilescope commented on Jun 12, 2018

@gilescope
Contributor

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

mati865 commented on Jan 10, 2019

@mati865
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-stack-probeArea: Stack probing and guard pagesC-bugCategory: This is a bug.O-muslTarget: The musl libc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sanxiyn@alexcrichton@brson@gilescope@mati865

        Issue actions

          Guard pages are disabled on musl. · Issue #31506 · rust-lang/rust