DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
211 stars 48 forks source link

Hanging test on Ubuntu 32-bit build #163

Open crisluengo opened 1 week ago

crisluengo commented 1 week ago

The CI tests for the 32-bit cross-compile build on Ubuntu have issues. The first time it ran, it showed a few tests failing, and then it hanged.

I've fixed all but one of the failing tests (FindHoughCircles still needs to be fixed).

The test program hangs during the execution of the test "[DIPlib] testing the SingularValueDecomposition and related functions" (src/support/matrix.cpp, line 569). I added "print debug statements", and saw it run all the way to the end of the test case, but doctest was not reporting the time it took to run that test, so it seems this is happening somewhere in the cleanup for the test case.

For the time being, I've disabled running the tests for this build.


For reference, the FindHoughCircles failed checks:

/home/runner/work/diplib/diplib/src/detection/hough.cpp:356:
TEST CASE:  [DIPlib] testing the FindHoughCircles function
/home/runner/work/diplib/diplib/src/detection/hough.cpp:371: ERROR: CHECK( cir[0] == dip::FloatArray{256, 256, 100} ) is NOT correct!
  values: CHECK( {350, 350, 25} == {256, 256, 100} )
/home/runner/work/diplib/diplib/src/detection/hough.cpp:372: ERROR: CHECK( cir[1] == dip::FloatArray{350, 350, 25} ) is NOT correct!
  values: CHECK( {260, 256, 103} == {350, 350, 25} )

The two circles are swapped, and one center is off by a few pixels in x and r.

crisluengo commented 5 days ago

The cause of the hang was an infinite loop in dip::GetOptimalDFTSize() caused by unsigned integer overflow. In the 64-bit case overflow didn’t happen because none of the test inputs were large enough to make that happen. But for the 32-bit case, one of the test cases was large enough. The relevant sources are here: https://github.com/DIPlib/diplib/blob/master/src/transform/dft_optimal_size.cpp

The algorithm was adapted from PocketFFT, here is the issue I submitted to that project: https://github.com/mreineck/pocketfft/issues/15

I have tried to fix the overflow problem. It no longer hangs but I haven’t gotten a correct algorithm yet. I think part of the solution will be to limit the size of the input, as suggested by the PocketFFT author.