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

panic on nightly: from_raw_parts safety contract violation #153

Closed
skibon02 opened this issue Feb 14, 2024 · 0 comments · Fixed by #157
Closed

panic on nightly: from_raw_parts safety contract violation #153

skibon02 opened this issue Feb 14, 2024 · 0 comments · Fixed by #157

Comments

@skibon02
Copy link
Contributor

skibon02 commented Feb 14, 2024

On latest nightly build my application fall into panic even before main function starts.
After figuring out, the problem was in file glue.rs:

unsafe { std::slice::from_raw_parts(saved_state_in as *const u8, saved_state_size) };

here, the saved_state_in is null in my case, which makes this operation violating safety contract.

To reproduce, create any minimal application with empty android_main function with native-activity feature.

Potentially, game activity code also have this issue, but wasn't tested

Panic message:

--------- beginning of crash
F/libc    ( 2629): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 2629 (penxr_framework), pid 2629 (penxr_framework)
I/RustStdoutStderr( 2629): thread '<unnamed>' panicked at library/core/src/panicking.rs:155:5:
I/RustStdoutStderr( 2629): 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`
I/RustStdoutStderr( 2629): note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I/RustStdoutStderr( 2629): thread caused non-unwinding panic. aborting.

rib pushed a commit that referenced this issue Apr 26, 2024
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: #153
@rib rib closed this as completed in #157 Apr 26, 2024
rib pushed a commit that referenced this issue Apr 26, 2024
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: #153
Athosvk pushed a commit to Traverse-Research/android-activity that referenced this issue Jul 10, 2024
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: rust-mobile#153
Athosvk pushed a commit to Traverse-Research/android-activity that referenced this issue Jul 10, 2024
Avoids calling `std::slice::from_raw_parts` with a null `saved_state_in`
pointer.

Fixes: rust-mobile#153
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

Successfully merging a pull request may close this issue.

1 participant