rust-x-bindings / rust-xcb

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

Panic: unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null #269

Open igor-petruk opened 2 months ago

igor-petruk commented 2 months ago

I haven't changed the code, but I might have updated something. Suddenly:

thread 'main' panicked at library/core/src/panicking.rs:220:5:
unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_nounwind_fmt
   2: core::panicking::panic_nounwind
   3: core::intrinsics::copy_nonoverlapping::precondition_check
             at /usr/obj/ports/rust-1.79.0/rustc-1.79.0-src/library/core/src/ub_checks.rs:66:21
   4: core::intrinsics::copy_nonoverlapping
             at /usr/obj/ports/rust-1.79.0/rustc-1.79.0-src/library/core/src/ub_checks.rs:73:17
   5: xcb::base::value_from_ptr
             at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xcb-1.4.0/src/base.rs:2073:5
   6: xcb::xproto::Visualtype::visual_id
             at ./target/debug/build/xcb-4540465e89c09db9/out/xproto.rs:5712:13
   7: oatbar::window::Window::create_and_show
             at ./src/window.rs:195:25
   8: oatbar::engine::Engine::new
             at ./src/engine.rs:74:26
   9: oatbar::main
             at ./src/main.rs:77:22
  10: core::ops::function::FnOnce::call_once
             at /usr/obj/ports/rust-1.79.0/rustc-1.79.0-src/library/core/src/ops/function.rs:250:5

The crash is here: https://github.com/igor-petruk/oatbar/blob/baf16278217012d9bec6c54e201d47379a263458/src/window.rs#L195

OpenBSD 7.5-snapshot, cargo run only, no problem in --release

rustc -V
rustc 1.79.0 (129f3b996 2024-06-10) (built from a source tarball)