rust-x-bindings / rust-xcb

Rust bindings and wrapper for XCB.
MIT License
161 stars 63 forks source link

This is a GE_GENERIC event! #257

Closed kvark closed 5 months ago

kvark commented 6 months ago

Seeing this crash on resizing a window made with GPUI:

Thread "main" panicked with "This is a GE_GENERIC event!" at /x/Code/zed/target/debug/build/xcb-86ab1d39fb35f267/out/xproto.rs:5110:9
   0: Zed::init_panic_hook::{closure#0}
             at crates/zed/src/main.rs:622:29
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
      std::panicking::rust_panic_with_hook
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic::<&str>::{closure#0}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:687:9
   3: std::sys_common::backtrace::__rust_end_short_backtrace::<std::panicking::begin_panic<&str>::{closure#0}, !>
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
   4: std::panicking::begin_panic::<&str>
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:686:12
   5: <xcb::xproto::Event as xcb::base::ResolveWireEvent>::resolve_wire_event
             at target/debug/build/xcb-86ab1d39fb35f267/out/xproto.rs:5110:9
   6: xcb::event::resolve_event
             at /home/kvark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xcb-1.3.0/src/event.rs:330:5
   7: <xcb::base::Connection>::handle_poll_for_event
             at /home/kvark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xcb-1.3.0/src/base.rs:1791:21
   8: <xcb::base::Connection>::poll_for_event
             at /home/kvark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xcb-1.3.0/src/base.rs:1226:13
   9: <gpui::platform::linux::x11::client::X11Client>::new::{closure#0}
             at crates/gpui/src/platform/linux/x11/client.rs:107:49
  10: <core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::generic::Generic<calloop::sources::generic::FdWrapper<alloc::rc::Rc<xcb::base::Connection>>, xcb::base::Error>, <gpui::platform::linux::x11::client::X11Client>::new::{closure#0}>> as calloop::sources::EventDispatcher<()>>::process_events::{closure#0}
             at /home/kvark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/mod.rs:327:61

For the record, GPUI is using calloop for processing X11 events:

// Safety: Safe if xcb::Connection always returns a valid fd
        let fd = unsafe { FdWrapper::new(Rc::clone(&xcb_connection)) };

        inner
            .loop_handle
            .insert_source(
                Generic::new_with_error::<xcb::Error>(
                    fd,
                    calloop::Interest::READ,
                    calloop::Mode::Level,
                ),
                {
                    let client = Rc::clone(&client);
                    move |_readiness, _, _| {
                        while let Some(event) = xcb_connection.poll_for_event()? {
                            client.handle_event(event);
                        }
                        Ok(calloop::PostAction::Continue)
                    }
                },
            )
            .expect("Failed to initialize x11 event source");