dima - 4 days ago

Hi. I'm trying to use the new mtfmapper Debian package, and I'm seeing it crash
with every image I give it. This happens:

$ mtf_mapper ....

....
mtf_mapper: .../src/mtf_core.cc:628: double Mtf_core::compute_mtf(Edge_model&, const std::map<int, scanline="">&, double&, double&, std::vector<double, std::allocator\<double=""> >&, std::vector<double, std::allocator\<double=""> >&, Snr&, bool): Assertion `fabs(magnitude[0] - 1.0) < 1e-6' failed.</double,></double,></int,>

I see this in every image I tried. The code in question is in src/mtf_core.cc:

double Mtf_core::compute_mtf(...) {
...
assert(fabs(magnitude[0] - 1.0) < 1e-6);
assert(fabs(smoothed[0] - 1.0) < 1e-6);
...
}

If I disabled the assertion, and print out the values being asserted, I see:

assert smoothed [0] = 0.99829302
assert magnitude[0] = 0.99829302
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000

assert smoothed [0] = 0.99877172
assert magnitude[0] = 0.99877172
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000

assert smoothed [0] = 0.99533649
assert magnitude[0] = 0.99533649
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000

assert smoothed [0] = 1.00179743
assert magnitude[0] = 1.00179743
assert smoothed [0] = 1.00000000
assert magnitude[0] = 1.00000000

....

So it fails the check a LOT. But the later reps generally converge to 1.0. Was
the intent to check the last rep only?

If I build from source I do NOT see the crashes because the default build flags
have -DNDEBUG, which disables the assert(). The Debian builds don't have
-DNDEBUG currently.

To make the Debian builds usable today, I'm about to remove the assert() there,
until this is fixed more correctly.

Thanks