From: kennytm Date: Sun, 4 Feb 2018 15:28:57 +0000 (+0800) Subject: Rollup merge of #47912 - cuviper:glibc-stack-guard, r=alexcrichton X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=8b8c6ee79613037e3a7886d1b80c34fcc538511b;p=rust.git Rollup merge of #47912 - cuviper:glibc-stack-guard, r=alexcrichton Use a range to identify SIGSEGV in stack guards Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863. --- 8b8c6ee79613037e3a7886d1b80c34fcc538511b