iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.68k stars 1.16k forks source link

OS error 4 from winit: "Interrupted system call" #932

Closed Ploppz closed 2 years ago

Ploppz commented 3 years ago

Using latest master of iced. When I Ctrl-C in my application:

^Cthread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 4, kind: Interrupted, message: "Interrupted system call" }', /home/ploppz/.cargo/git/checkouts/winit-57d3141eaf559308/9c35895/src/platform_impl/linux/x11/mod.rs:360:54
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4e3e6db011c5b482d2bef8ba02274657f93b5e0d/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/4e3e6db011c5b482d2bef8ba02274657f93b5e0d/library/core/src/panicking.rs:92:14
   2: core::result::unwrap_failed
             at /rustc/4e3e6db011c5b482d2bef8ba02274657f93b5e0d/library/core/src/result.rs:1355:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/4e3e6db011c5b482d2bef8ba02274657f93b5e0d/library/core/src/result.rs:1037:23
   4: winit::platform_impl::platform::x11::EventLoop<T>::run_return
             at /home/ploppz/.cargo/git/checkouts/winit-57d3141eaf559308/9c35895/src/platform_impl/linux/x11/mod.rs:360:17
   5: winit::platform_impl::platform::x11::EventLoop<T>::run
             at /home/ploppz/.cargo/git/checkouts/winit-57d3141eaf559308/9c35895/src/platform_impl/linux/x11/mod.rs:385:9
   6: winit::platform_impl::platform::EventLoop<T>::run
             at /home/ploppz/.cargo/git/checkouts/winit-57d3141eaf559308/9c35895/src/platform_impl/linux/mod.rs:670:56
   7: winit::event_loop::EventLoop<T>::run
             at /home/ploppz/.cargo/git/checkouts/winit-57d3141eaf559308/9c35895/src/event_loop.rs:154:9
   8: iced_winit::application::run
             at /home/ploppz/.cargo/git/checkouts/iced-9e73d2fbe1fce35a/1b6cf05/winit/src/application.rs:168:5
   9: iced::application::Application::run
             at /home/ploppz/.cargo/git/checkouts/iced-9e73d2fbe1fce35a/1b6cf05/src/application.rs:219:16
  10: bup::main
             at ./src/main.rs:133:5
  11: core::ops::function::FnOnce::call_once
             at /rustc/4e3e6db011c5b482d2bef8ba02274657f93b5e0d/library/core/src/ops/function.rs:227:5

This is my application https://github.com/Ploppz/bup/commit/62f344465837575620fbf5de92942b5663a51839

I have ctrlc handler, not sure if it matters:

    ctrlc::set_handler(move || {
        SHOULD_EXIT.store(true, std::sync::atomic::Ordering::Relaxed);
    })
hecrj commented 2 years ago

This looks like a winit issue!

In any case, I recommend you to leverage events_with together with Application::should_exit.