Repository navigation
Closed
Labels
DS - x11Affects the X11 backend, or generally free Unix platforms
Description
Possibly related to #79, but I'm raising this separately because there is no way for an application to trap this fault.
The issue is that the internal maps are no longer consistent / are invalidated after the drop and the event processing uses unwrap when accessing them.
Example program:
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let _window1 = Some(winit::Window::new(&events_loop).unwrap());
let mut window2 = Some(winit::Window::new(&events_loop).unwrap());
let _window3 = Some(winit::Window::new(&events_loop).unwrap());
let mut num_windows = 3;
drop(window2.take());
events_loop.run_forever(|event| {
match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => {
num_windows -= 1;
if num_windows == 0 {
return winit::ControlFlow::Break;
}
},
_ => (),
}
winit::ControlFlow::Continue
})
}
Stack trace:
Breakpoint 1, rust_panic () at libstd/panicking.rs:433
433 libstd/panicking.rs: No such file or directory.
(gdb) bt
#0 rust_panic () at libstd/panicking.rs:433
#1 0x00005555556d369f in std::panicking::rust_panic_with_hook () at libstd/panicking.rs:418
#2 0x00005555556d3423 in std::panicking::begin_panic_fmt () at libstd/panicking.rs:349
#3 0x00005555556d3353 in rust_begin_unwind () at libstd/panicking.rs:325
#4 0x0000555555712be1 in core::panicking::panic_fmt () at libcore/panicking.rs:72
#5 0x0000555555712b07 in core::panicking::panic () at libcore/panicking.rs:51
#6 0x00005555555784aa in <core::option::Option<T>>::unwrap (self=...) at /checkout/src/libcore/macros.rs:20
#7 0x000055555557a2cb in winit::platform::platform::x11::EventsLoop::process_event (self=0x7fffffffda40, xev=0x7fffffffd8b8, callback=0x7fffffffd980)
at /home/wez/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.11.1/src/platform/linux/x11/mod.rs:360
#8 0x0000555555578e57 in winit::platform::platform::x11::EventsLoop::run_forever (self=0x7fffffffda40, callback=...)
at /home/wez/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.11.1/src/platform/linux/x11/mod.rs:188
#9 0x000055555556c428 in winit::platform::platform::EventsLoop::run_forever (self=0x7fffffffda38, callback=...)
at /home/wez/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.11.1/src/platform/linux/mod.rs:399
#10 0x000055555556fb68 in winit::EventsLoop::run_forever (self=0x7fffffffda38, callback=...)
at /home/wez/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.11.1/src/lib.rs:231
#11 0x0000555555575881 in winitbug::main () at src/main.rs:14
Metadata
Metadata
Assignees
Labels
DS - x11Affects the X11 backend, or generally free Unix platforms
Activity
We can now spawn additional windows
francesca64 commentedon Mar 4, 2018
I've created a branch that should solve both this and #79.
The way I implemented
DropforWindowis sort of surprising, since all it does is send aWM_DELETE_WINDOWClientMessage, which the event loop then handles to do the actual cleanup and destroying. I'm not sure how kosher that is on a conceptual level (in terms of what users expectDropto be responsible for), but it behaves the best of anything I've tried.I've also found that the old
Dropimplementation freezes the event loop, which I've determined to be related to the mutex locking. I still don't understand exactly why that was an issue, but now that the locking is done in the event loop, everything works fine.x11: Destroy dropped windows; handle WM_DELETE_WINDOW
x11: Destroy dropped windows; handle WM_DELETE_WINDOW
x11: Destroy dropped windows; handle WM_DELETE_WINDOW
x11: Destroy dropped windows; handle WM_DELETE_WINDOW
x11: Destroy dropped windows; handle WM_DELETE_WINDOW
x11: Destroy dropped windows; handle WM_DELETE_WINDOW (#416)
francesca64 commentedon Mar 23, 2018
Fixed via #416
x11: Destroy dropped windows; handle WM_DELETE_WINDOW (rust-windowing…
Auto merge of rust-windowing#414 - pcwalton:radial-gradient-epsilon, …