Skip to content
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

Panic with ControlFlow::Wait when computer goes to sleep on Linux/X11 #1947

Open
jfrimmel opened this issue May 21, 2021 · 1 comment
Open
Labels
B - bug Dang, that shouldn't have happened C - waiting on author Waiting for a response or another PR DS - x11

Comments

@jfrimmel
Copy link

Hello,

I encountered a panic within winit when putting my closing and re-opening the lid on my laptop (i.e. when sleep mode is entered) while executing the winit (version 0.24+) application:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 4, kind: Interrupted, message: "Interrupted system call" }', /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/x11/mod.rs:360:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The platform is Linux with only the x11 feature enabled. I haven't checked other platforms.

Reproduction

$ cargo new winit-sleep-linux
$ cd winit-sleep-linux
$ echo 'winit = { version = "0.25", default-features = false, features=["x11"]}' >> Cargo.toml
$ nano src/main.rs # insert code below
$ cargo run # close the lid/enter sleep otherwise; wait a short time; open the lid/leave sleep mode

The content of src/main.rs is very simle and reduced, it does not even contain a window:

fn main() {
    let event_loop = winit::event_loop::EventLoop::new();
    event_loop.run(|_, _, control_flow| *control_flow = winit::event_loop::ControlFlow::Wait);
}

Backtrace

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 4, kind: Interrupted, message: "Interrupted system call" }', /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/x11/mod.rs:360:54
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/option.rs:1329:5
   3: core::result::Result<T,E>::unwrap
             at /home/jfrimmel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
   4: winit::platform_impl::platform::x11::EventLoop<T>::run_return
             at /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/x11/mod.rs:360:17
   5: winit::platform_impl::platform::x11::EventLoop<T>::run
             at /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/x11/mod.rs:385:9
   6: winit::platform_impl::platform::EventLoop<T>::run
             at /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/platform_impl/linux/mod.rs:662:56
   7: winit::event_loop::EventLoop<T>::run
             at /home/jfrimmel/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.25.0/src/event_loop.rs:154:9
   8: winit_sleep_linux::main
             at ./src/main.rs:3:5
   9: core::ops::function::FnOnce::call_once
             at /home/jfrimmel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@jfrimmel jfrimmel changed the title Panic with ControlFlow::Waitwhen computer goes to sleep on Linux/X11 Panic with ControlFlow::Wait when computer goes to sleep on Linux/X11 May 21, 2021
@jfrimmel
Copy link
Author

I've created a patch (#1952), that prevents the panic in the example above. One can test this out by adding the following two lines to the Cargo.toml from above:

[patch.crates-io]
winit = { git = "https://github.com/jfrimmel/winit", branch = "x11-interrupt" }

@maroider maroider added DS - x11 C - waiting on author Waiting for a response or another PR B - bug Dang, that shouldn't have happened labels Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - waiting on author Waiting for a response or another PR DS - x11
Development

Successfully merging a pull request may close this issue.

2 participants