Skip to content

[Bug] linemod::match crashes with SIGSEGV due to misaligned store in orUnaligned8u #29559

Description

@12345an1

System Information

  • OpenCV version: 5.0.0 (contrib)
  • Operating System: Arch Linux
  • Compiler: GCC 14
  • CPU: Intel Core i7-9750H(SSE2 / SSE3 supported)

Detailed description

When calling cv::linemod::Detector::match(), the process crashes with a segmentation fault deep inside the SIMD-optimized helper function orUnaligned8u. The crash occurs because the function uses an aligned store instruction (_mm_or_si128 with dereferenced __m128i*) on a destination pointer that is not guaranteed to be 16-byte aligned.

Steps to reproduce

  1. Create a linemod detector, add at least one template using a reference image and a binary mask.
  2. Prepare a test image whose width (in bytes) is not a multiple of 16 (e.g., width = 218 for a 3-channel image, giving a stride of 654).
  3. Call detector->match(sources, threshold, matches).

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions