Skip to content

panic on nightly: from_raw_parts safety contract violation #153

@skibon02

Description

@skibon02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions