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:
> 
> https://github.com/rust-lang/rust/issues/43052

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!
-- 
Michal Hocko
SUSE Labs

Reply via email to