-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Since last nightly, winit doesn't create windows any more #43102
Comments
Obviously this also affects glium examples. |
Using rust-bisect I've bisected the regression to #42816 (cd72f2e). cc @alexcrichton @nikomatsakis . |
Minimized example using only the extern crate x11_dl;
pub use x11_dl::xlib::Xlib;
pub use x11_dl::xcursor::Xcursor;
use x11_dl::error::OpenError;
fn foo() -> Result<Xlib, OpenError> {
// opening the libraries
println!("new 1");
let xlib = try!(Xlib::open());
println!("new 2");
let _xcursor = try!(Xcursor::open());
Ok(xlib)
}
fn main() {
foo().unwrap();
println!("Good!");
} On the old nightly it prints |
Issue doesnt occur when running in a seperate thread: extern crate x11_dl;
pub use x11_dl::xlib::Xlib;
pub use x11_dl::xcursor::Xcursor;
use x11_dl::error::OpenError;
use std::thread;
use std::time::Duration;
fn foo() -> Result<Xlib, OpenError> {
// opening the libraries
println!("new 1");
let xlib = try!(Xlib::open());
println!("new 2");
let _xcursor = try!(Xcursor::open());
Ok(xlib)
}
fn main() {
thread::spawn(|| {
foo().unwrap();
});
thread::sleep(Duration::new(999,0));
} |
The location at which the stack overflow occurs seems to be here. full backtrace (expand)
|
The problem is probably that a |
Ok I believe that this is going to be fixed with rust-lang/compiler-builtins#176. Once that lands I'll open a PR to pull it into rust-lang/rust. After some debugging with @est31 I also was recommended by @cuviper to cc @bwhacks here as well as I'm told you're working on the kernel side of some changes here. @bwhacks you may be quite interested in this patch! First it may help to give you some background. Everyone seems super interested in big stacks nowadays in lots of different ways! A few days ago we landed a change which switched to using stack probes on all x86/x86_64 platforms. This uses upstream LLVM's support for emitting a call to a function as part of the prologue for a function, and the intention is to touch each page of a stack frame to ensure they're all mapped. Basically we just want to guarantee that for all threads on all platforms if you have a guard page you'll hit it. The actual stack probing function is in this file (note that this link is current as-of the time of this writing) which we define locally and LLVM controls the ABI of how its called (register-wise and whatnot). Unfortunately though it looks like the addition of stack probes has caused this issue as a regression as well as #43110. After debugging this with @est31 we noticed that the segfault in this issue (the program in the comment above) was suspicious in that it was faulting just below the end of the stack. In other words, the segfault was happening just below the lowest-address of the mapped stack, but within a page of the lowest stack address. I'm personally quite unfamiliar with the implementation of stack growth in the kernel, but the investigation on #43052 clued me into at least some changes happening on the kernel side recently. Based on this I stabbed in the dark with rust-lang/compiler-builtins@f9f6bd0 and it ended up fixing the regression for @est31 (fixing this issue). So with all that said, I think that this may be another case where the recent changes in the kernel related to stack growth may have accidentally broken programs. My guess is that the kernel previously grew the stack for any fault within a certin range, but nowadays it looks like it also has a condition that the faulting page has to be above the stack pointer. Our Note that this isn't really a problem for us. The |
One more detail - we were seeing this even after removing Rust's custom guard page, so it seems not to be an issue with the new padding. More like the kernel is putting new constraints on stack growth below the actual stack pointer. Maybe it's enforcing no access farther than the x86_64 red zone? (128 bytes) |
Hmm, the x86 page fault handler checks
So "always a bug" but allows some cushion anyway -- yet it seems like we aren't getting that allowance. This code has not been changed in many years, nor does it appear to be changed in the Fedora kernel I'm running. |
Many thanks @alexcrichton for you looking into this issue! |
This issue is made worse by the fact that |
There is no red zone in Windows and (IIRC) you must always move the stack pointer below any address before you access something at that address. |
Update compiler_builtins submodule for probestack fix Closes #43102
Doing the following:
gives me a window on stable, beta, and
1.20.0-nightly (3610a70ce 2017-07-05)
.On
1.20.0-nightly (696412de7 2017-07-06)
I get no window.List of the commits.
Platform is Linux/X11.
cc @tomaka
The text was updated successfully, but these errors were encountered: