Re: [PATCH] mm: larger stack guard gap, between vmas
From: Michal Hocko
Date: Tue Jul 04 2017 - 10:48:38 EST
On Tue 04-07-17 14:19:00, Ximin Luo wrote:
> I've written up an explanation of what happens in the Rust case here:
The most important part is https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/thread.rs#L248
// Rellocate the last page of the stack.
// This ensures SIGBUS will be raised on
// stack overflow.
let result = mmap(stackaddr, psize, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
so this is basically the same thing Java does. Except that Java doesn't
do that on main thread usually. Only some JNI runtimes do that.
pthread_attr_getstack() usage on the main thread sounds like a real bug
in rust to me.
Thanks for the writeup!