Fix LineSegmentDetector segfault caused by C++/C# calling convention mismatch - #1877
Conversation
…eptionStatus pattern The migration in #1846 updated the C# P/Invoke declarations for imgproc_Ptr_LineSegmentDetector_get and imgproc_Ptr_LineSegmentDetector_delete to use the ExceptionStatus + out-parameter convention, but the corresponding C++ implementations were left in the old direct-return style, causing a calling-convention mismatch that resulted in a null RawPtr and subsequent segfault. Closes #1876. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates the LineSegmentDetector C++ wrapper functions to return ChangesLineSegmentDetector wrapper and validation
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #1876.
LineSegmentDetector.Create()returned an instance with a nullRawPtrin 4.13.0.20260427, causing a segfault onDetect().Root cause
PR #1846 updated the C# P/Invoke declarations for
imgproc_Ptr_LineSegmentDetector_getandimgproc_Ptr_LineSegmentDetector_deleteto the newExceptionStatus+ out-parameter convention, but the corresponding C++ implementations inimgproc_LineSegmentDetector.hwere left in the olddirect-return style. The calling-convention mismatch caused
rawPtrto be populated with garbage/null, leading to the segfault.Fix
Update the two C++ functions to match the convention already used everywhere else in the codebase (e.g.
bgsegm.h,calib3d_StereoMatcher.h):ExceptionStatusinstead ofvoid/ raw pointerBEGIN_WRAP/END_WRAPAlso adds
LineSegmentDetectorTestcovering the exact repro case from the issue.Summary by CodeRabbit
Tests
Refactor