progressive-x icon indicating copy to clipboard operation
progressive-x copied to clipboard

Segmentation Fault in FundamentalMatrixSevenPointSolver

Open fkluger opened this issue 1 year ago • 0 comments

Hi,

I am running some experiments with F-Matrix estimation and am occasionally encountering segmentation faults.

GDB gave me this:

#0  gcransac::estimator::solver::FundamentalMatrixSevenPointSolver::estimateModel (this=this@entry=0x7fffffff9da8, data_=..., sample_=sample_@entry=0x0, sample_number_=7, models_=..., weights_=weights_@entry=0x0)
    at /home/kluger/projects/remote/progressive-x/graph-cut-ransac/src/pygcransac/include/estimators/solver_fundamental_matrix_seven_point.h:103
103                                             const int sample_idx = sample_[i];

(gdb) p sample_
$7 = (const size_t *) 0x0

So sample_ appears to be nullptr and FundamentalMatrixSevenPointSolver::estimateModel does not handle this.

I noticed this case is handled in FundamentalMatrixBundleAdjustmentSolver::estimateModel:

if (sample_ == nullptr)
	sample_number_ = data_.rows;

If sample_number_ is greater than seven, the Eight-Point-Solver is used instead.

However, in this particular case:

(gdb) p data_.rows
$8 = 7

So the Seven-Point-Solver is still called because sample_number_ = 7, which then segfaults because sample_ = nullptr.

I will try adding another check to FundamentalMatrixSevenPointSolver::estimateModel for sample_ == nullptr to avoid the segfault, but I don't know if this is the correct way to fix this bug.

Best wishes, Florian

fkluger avatar Aug 15 '23 13:08 fkluger