How does the stack's guard page work on amd64?
Alan Somers
asomers at freebsd.org
Tue Mar 30 05:06:51 UTC 2021
Rust tries to detect stack overflow and handles it differently than other
segfaults, but it's currently broken on FreeBSD/amd64. I've got a patch
that fixes the problem, but I would like someone to confirm my reasoning.
It seems like FreeBSD's main thread stacks include a guard page at the
bottom. However, when Rust tries to create its own guard page (by
re-mmap()ping and mprotect()ing it), it seems like FreeBSD's guard page
automatically moves up into the un-remapped region. At least, that's how
it behaves, based on the addresses that segfault. Is that correct?
For other threads, Rust doesn't try to remap the guard page, it just relies
on the guard page created by libthr in _thr_stack_alloc.
Finally, what changed in between FreeBSD 10.3 and 11.4? Rust's stack
overflow detection worked in 10.3.
-Alan
More information about the freebsd-hackers
mailing list