Skip to content

Segmentation fault in release build on MacOS M1 - the slice returned by data_u8() has a null pointer address #9

@apps4uco

Description

@apps4uco

Hi,

I have discovered an issue when compiling with --release on a Mac M1
the slice returned by data_u8() has a null pointer.

let camera = Camera::new_default_device();
camera.start();
camera.wait_for_frame();

if let Some(camera_frame)=self.frame.as_ref() {
            debug!("Getting frame data");
            let data=camera_frame.data();
            debug!("frame data u32 ok");
            let data_u8=data.data_u8();
            debug!("frame data u8 ok len {}",data_u8.len());
            debug!("frame data u8 ptr {:?}",data_u8.as_ptr());
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] step
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] frame ready
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] Getting frame data
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] frame data u32 ok
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] frame data u8 ok len 3686400
[2023-10-05T15:42:31Z DEBUG i2ucam_desktop] frame data u8 ptr 0x0
zsh: segmentation fault  cargo run --release

uname -a
Darwin andy-mac-m1 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103 arm64

It fails on nightly and on stable

rustc -V
rustc 1.74.0-nightly (9f5fc1bd4 2023-09-02)

rustc -V
rustc 1.72.0 (5680fa18f 2023-08-23)

However, it works fine in a debug build.

I made a PR that although doesnt fix the problem removed a block of unsafe code, and adds the logging crate.

My hunch is that one of the buffers in the native code is getting dropped in release builds and should be copied earlier, but thats just a guess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions