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

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

Open
apps4uco opened this issue Oct 5, 2023 · 1 comment · May be fixed by #11

Comments

@apps4uco
Copy link

apps4uco commented Oct 5, 2023

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.

@Uriopass
Copy link

Uriopass commented May 20, 2024

Had the same problem. The issue is that CVPixelBufferLockBaseAddress(ibuf, 1) }; needs to be called, but it is only done in debug mode. Opened #11 .

@Uriopass Uriopass linked a pull request May 20, 2024 that will close this issue
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.

2 participants