Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.65k stars 465 forks source link

Unsafe precondition(s) violated with `sdl2::init()` in test mode #1402

Closed AlixANNERAUD closed 4 weeks ago

AlixANNERAUD commented 4 weeks ago

Hi, I am encountering an error that I did not have before with the same code base. This error only occurs in test mode (possibly in debug mode).

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

Here is the full stack backtrace :

stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:110:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:123:9
   3: core::panicking::panic_nounwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:156:5
   4: core::slice::raw::from_raw_parts::precondition_check
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/intrinsics.rs:2799:21
   5: core::slice::raw::from_raw_parts
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/slice/raw.rs:98:9
   6: strncmp
             at /home/alix_anneraud/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lvgl-sys-0.6.2/src/string_impl.rs:118:14
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: sdl2::sdl::Sdl::new
             at /home/alix_anneraud/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-0.36.0/src/sdl2/sdl.rs:102:26
  14: sdl2::sdl::init
             at /home/alix_anneraud/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-0.36.0/src/sdl2/sdl.rs:387:5

This indicates that the error originates from here. I believe this issue is related to the Rust compiler 1.78 release and the asserting unsafe preconditions.