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

Ensure cam_frame_t structure is correctly aligned #622

Closed
igrr opened this issue Jan 22, 2024 · 2 comments
Closed

Ensure cam_frame_t structure is correctly aligned #622

igrr opened this issue Jan 22, 2024 · 2 comments
Labels
bug Something isn't working no-issue-activity

Comments

@igrr
Copy link
Member

igrr commented Jan 22, 2024

From the discussion in esp-rs/esp-idf-sys#278 and esp-rs/rust#195:

In this line:

cam_obj->frames = (cam_frame_t *)heap_caps_calloc(1, cam_obj->frame_cnt * sizeof(cam_frame_t), MALLOC_CAP_DEFAULT);

we need to use heap_caps_aligned_calloc and request 8-byte alignment, since alignof(cam_frame_t) is 8 bytes.

(The code "works" as is, but would trigger UBSAN if it was enabled (-fsanitize=undefined) and is also resulting in the unaligned pointer error on Rust side, since the pointer returned by heap_caps_calloc may not meet the alignment requirements.)

@igrr igrr added the bug Something isn't working label Jan 22, 2024
@AxelLin
Copy link

AxelLin commented Jan 24, 2024

Fixed by 8df17f7.

Copy link

This issue appears to be stale. Please close it if its no longer valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
None yet
Development

No branches or pull requests

2 participants