Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread 'main' panicked #362

Open
carlolalu opened this issue Sep 11, 2024 · 3 comments
Open

thread 'main' panicked #362

carlolalu opened this issue Sep 11, 2024 · 3 comments

Comments

@carlolalu
Copy link

carlolalu commented Sep 11, 2024

Following the tutorial on Hands-on Rust I found that compiling flappy I get this error:

thread 'main' panicked at library/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 do not use nightly rust, and my setup was completely following the book. Searching online I found this issue https://github.com/KyleMayes/vulkanalia/issues/254. Could it be related somehow?

@sisso
Copy link

sisso commented Sep 21, 2024

I have a project that was working yesterday and today is having this issue. From stackoverflow

A recent change to the standard library enabled debug assertions in core/std to fire if the user compiles in debug mode

That appears to be on rust 1.78, I downgrade my project to 1.77.1 (not sure why 1.77.2 toolchain fail to install):

rustup install 1.77.1
echo "1.77.1" > rust-toolchain

The workarounds appears to be:

  1. You need to wait for a fix (not sure where)
  2. compile on release mode
  3. use a older toolchain < 1.78

redkite added a commit to redkite/rusty-dungeon that referenced this issue Oct 20, 2024
@MichaelMackus
Copy link

This appears related to the wayland backend on linux, at least it was for me. You can also workaround this error by running it via the x11 winit backend x11: WINIT_UNIX_BACKEND=x11 cargo run

I'm not sure why this is failing, since the winit examples run fine for me in wayland.

@MichaelMackus
Copy link

Ah, I've traced it down to the glutin version that is tagged. When I try to run the window example in glutin v0.29.1 I get the same error from glutin:

thread 'main' panicked at library/core/src/panicking.rs:219: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

The glutin examples work fine at the latest version. Not sure how easy that is to upgrade, but it could just be a version change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants