Invalid arguments cause application crash (segfault) instead of raising an exception
Description
When passing incompatible/invalid arguments to certain gem objects backed by the C++ OpenCV API, the entire Ruby process crashes with a segmentation fault instead of raising a proper Ruby exception (e.g. TypeError or ArgumentError).
This makes it impossible to rescue from such errors, and a single accidental misuse of the API brings down the whole application.
Steps to reproduce
require "opencv-ruby"
Cv::ThresholdTypes::THRESH_BINARY | 1 # crash
Cv::Scalar.new + 1 # crash
Cv::Vec3b.new + 1 # crash
Expected behavior
An appropriate Ruby exception should be raised (e.g. TypeError: no implicit conversion of Integer into ...), allowing the caller to rescue and handle the error gracefully.
Actual behavior
The Ruby process crashes with a segmentation fault. Segfault log attached.
Environment
- Gem:
opencv-ruby
- Ruby: 4.0.1 (2026-01-13 revision e04267a14b) +PRISM
- OS: Ubuntu 23.04 (kernel 6.2.0-39-generic)
Notes
The operations themselves are logically invalid and are not expected to succeed - the issue is solely that the error surfaces as a native crash rather than a rescuable Ruby exception.
Fault info
fault.txt
Invalid arguments cause application crash (segfault) instead of raising an exception
Description
When passing incompatible/invalid arguments to certain gem objects backed by the C++ OpenCV API, the entire Ruby process crashes with a segmentation fault instead of raising a proper Ruby exception (e.g.
TypeErrororArgumentError).This makes it impossible to rescue from such errors, and a single accidental misuse of the API brings down the whole application.
Steps to reproduce
Expected behavior
An appropriate Ruby exception should be raised (e.g.
TypeError: no implicit conversion of Integer into ...), allowing the caller to rescue and handle the error gracefully.Actual behavior
The Ruby process crashes with a segmentation fault. Segfault log attached.
Environment
opencv-rubyNotes
The operations themselves are logically invalid and are not expected to succeed - the issue is solely that the error surfaces as a native crash rather than a rescuable Ruby exception.
Fault info
fault.txt