Skip to content

rgbd(linemod): fix segfault in unaligned memory access - #4180

Open
omarwael-24 wants to merge 6 commits into
opencv:4.xfrom
omarwael-24:fix-linemod-unaligned-access
Open

rgbd(linemod): fix segfault in unaligned memory access#4180
omarwael-24 wants to merge 6 commits into
opencv:4.xfrom
omarwael-24:fix-linemod-unaligned-access

Conversation

@omarwael-24

Copy link
Copy Markdown

Bug Description

Calling linemod::match with unaligned memory buffers (such as sub-matrices generated via cv::Rect offsets) caused a SIGSEGV crash inside orUnaligned8u.
The issue stemmed from raw pointer casting that assumed strict memory alignment constraints.

Fix Details

  • Replaced manual pointer arithmetic and unsafe type casting in orUnaligned8u with OpenCV Universal Intrinsics (vx_load, vx_store, and v_or).
  • Ensures safe and platform-agnostic memory access for non-16-byte aligned buffers across supported architectures.
  • Added a regression test (RGBD_Linemod.MatchUnaligned) to verify stability when executing matches on unaligned inputs.

Testing

Ran the standalone test target:
./bin/opencv_test_rgbd --gtest_filter=*MatchUnaligned*
Result: [ PASSED ] 1 test.

…perations

orUnaligned8u crashed with SIGSEGV when image stride was not 16-byte aligned.
The previous code used aligned dereferencing on dst pointers and checked src
alignment only once before the row loop.

This replaces raw SSE intrinsics with OpenCV universal intrinsics. It ensures
safe unaligned loads and stores for both src and dst across all rows.

Fixes #29559
…perations

orUnaligned8u crashed with SIGSEGV when image stride was not 16-byte aligned.
The previous code used aligned dereferencing on dst pointers and checked src
alignment only once before the row loop.

This replaces raw SSE intrinsics with OpenCV universal intrinsics. It ensures
safe unaligned loads and stores for both src and dst across all rows.

Create a test file for linemod.cpp
Fixes #29559
Fix SIGSEGV in orUnaligned8u caused by unsafe memory alignment assumptions.
Replaced raw pointer casting with OpenCV universal intrinsics (vx_load,
vx_store, v_or) to safely support non-16-byte aligned buffers across
architectures. Added a unit test to verify stability with unaligned inputs.
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 this pull request may close these issues.

1 participant