rust-x-bindings / rust-xcb

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

Panicking: Misaligned pointer dereference when sending client message #235

Closed cartoon-raccoon closed 1 year ago

cartoon-raccoon commented 1 year ago

My program panics with a misaligned pointer dereference error when I try to send an event. I'm sending a ClientMessage event from the root window.

Attached is the rust backtrace of the panic, with irrelevant function calls removed: crashlog.txt

And this is the relevant code that's calling the function:

let event = x::ClientMessageEvent::new(
    // cast! is just calling <<type> as XidNew>::new(id)
    cast!(x::Window, window),
    cast!(x::Atom, data.type_),
    to_send // client message data
);

Ok(self.conn.check_request(self.conn.send_request_checked(
    &x::SendEvent{
        propagate: false,
        destination: x::SendEventDest::Window(cast!(x::Window, window)),
        event_mask: x::EventMask::NO_EVENT,
        event: &event,
    }
))?)

I am aware that cast! is calling unsafe code, but I'm fairly sure that all values that it's dealing with already exist on the server.

rtbo commented 1 year ago

Have you tested with the main branch? This was very likely fixed by #229

cartoon-raccoon commented 1 year ago

I'm using v1.2.1 from Crates.io. I'll do some further testing with the latest commit on the main branch to see if it's fixed.

hydrobeam commented 1 year ago

I was having a similar issue that was fixed by switching to the main branch.

Is there going to be a new release to make the fix available?

rtbo commented 1 year ago

v1.2.2 is published