I am just starting out learning Rust using the book "Hands-on Rust: Effective Learning through 2D Game Development and Play" by Herbert Wolverson.
I'm currently at Part I.3 and am tasked with building a simple game using bracket-lib.
I should be able to run a simple "Hello, world" in the book, but trying to run cargo run
results in the following error:
thread 'main' panicked at core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed 'isize::MAX'
note: run with 'RUST_BACKTRACE=1' environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
I rechecked every line but was not able to find any issues with it. VSCode with rust-analyzer also does not show any issues.
I uploaded the code here:
Maybe someone could point me in the right direction. I appreciate any help provided.
OS used: Fedora 41 (fully patched)
Rustup Ver: rustup 1.27.1 (54dd3d00f 2024-04-24)
rustc Ver: rustc 1.83.0 (90b35a623 2024-11-26)
I am just starting out learning Rust using the book "Hands-on Rust: Effective Learning through 2D Game Development and Play" by Herbert Wolverson.
I'm currently at Part I.3 and am tasked with building a simple game using bracket-lib.
I should be able to run a simple "Hello, world" in the book, but trying to run cargo run
results in the following error:
thread 'main' panicked at core/src/panicking.rs:221:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed 'isize::MAX'
note: run with 'RUST_BACKTRACE=1' environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
I rechecked every line but was not able to find any issues with it. VSCode with rust-analyzer also does not show any issues.
I uploaded the code here: https://github.com/flashkiller999/learning_rust
Maybe someone could point me in the right direction. I appreciate any help provided.
OS used: Fedora 41 (fully patched)
Rustup Ver: rustup 1.27.1 (54dd3d00f 2024-04-24)
rustc Ver: rustc 1.83.0 (90b35a623 2024-11-26)
Thanks for the answers, the problem is upstream in bracket-lib, it seems to be broken on Wayland environments at the moment as mentioned in the link from Ry- & user2722968 (https://github.com/amethyst/bracket-lib/issues/362)
I was able to workaround the issue with the workaround mention in the bug report, via using X11 instead of Wayland: WINIT_UNIX_BACKEND=x11 cargo run
For using the workaround in VSCode I edited the launch.json and added the environment variable to it:
"env": {
"WINIT_UNIX_BACKEND": "x11"
}
rustc
and its targets setup. – Raeisi Commented Jan 5 at 13:17