Skip to content

BUG: fix an infinite loop in itk::VoronoiDiagram2DGenerator#5400

Open
ILoveGoulash wants to merge 2 commits intoInsightSoftwareConsortium:mainfrom
ILoveGoulash:fix-voronoi-diagram-2d-generator-inf-loop
Open

BUG: fix an infinite loop in itk::VoronoiDiagram2DGenerator#5400
ILoveGoulash wants to merge 2 commits intoInsightSoftwareConsortium:mainfrom
ILoveGoulash:fix-voronoi-diagram-2d-generator-inf-loop

Conversation

@ILoveGoulash
Copy link

@ILoveGoulash ILoveGoulash commented Jun 16, 2025

The loop exit condition was present in the code, but never wired and removed via cd97879

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

Refer to the ITK Software Guide for
further development details if necessary.

@github-actions github-actions bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances area:Segmentation Issues affecting the Segmentation module labels Jun 16, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing a pull request! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜
More support and guidance on the contribution process can be found in our contributing guide. 📖

This is an automatic message. Allow for time for the ITK community to be able to read the pull request and comment
on it.

@dzenanz dzenanz requested review from hjmjohnson and seanm June 16, 2025 13:45
@ILoveGoulash
Copy link
Author

Don't know if you want a regression test, and if your framework can handle "infinite looping" type failures.

@dzenanz
Copy link
Member

dzenanz commented Jun 16, 2025

A regression test is advantageous. I don't think we have an explicit support for infinite looping, but such a test would fail via timeout.

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Jun 16, 2025
@ILoveGoulash
Copy link
Author

Added the original case by doing "monkey see monkey do", but it looks like I can't build locally due to IPFS + work firewall or something.

@ILoveGoulash ILoveGoulash force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch 2 times, most recently from f5ff22b to 62457de Compare June 16, 2025 14:39
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can reproduce locally an infinite loop with this test.

@dzenanz
Copy link
Member

dzenanz commented Jun 16, 2025

@bradking Is ghostflow acting up? Commit 62457de has a very short commit message.

@ILoveGoulash
Copy link
Author

Nah, the full "http://..." link is probably what triggers it, GitHub prettifies it on display.

@ILoveGoulash ILoveGoulash force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch from 62457de to 288b65e Compare June 16, 2025 14:51
@hjmjohnson
Copy link
Member

@ILoveGoulash Thank you for your contribution. There are just a few final actions that need to be finalized so that we can incorporate this into the main tree.

@ILoveGoulash ILoveGoulash force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch from 288b65e to 380c33d Compare August 14, 2025 07:24
@ILoveGoulash
Copy link
Author

Should be okay now.

@hjmjohnson hjmjohnson force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch 2 times, most recently from 8f868e4 to c6ccef6 Compare August 14, 2025 12:57
@hjmjohnson
Copy link
Member

@ILoveGoulash I rebased and removed the merge conflict, then updated the commit message for the regression test to be more descriptive.

@ILoveGoulash
Copy link
Author

Thanks!

@hjmjohnson hjmjohnson force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch from c6ccef6 to cec88e2 Compare August 14, 2025 16:05
@ILoveGoulash
Copy link
Author

Ping.

The loop exit condition was present in the code, but never wired and removed via InsightSoftwareConsortium@cd97879

Fixes InsightSoftwareConsortium#4386
@hjmjohnson hjmjohnson force-pushed the fix-voronoi-diagram-2d-generator-inf-loop branch from 4aa2b26 to ddccb03 Compare January 28, 2026 15:33
Comment on lines +23 to +27
itkVoronoiDiagram2DInfiniteLoopTest(int argc, char * argv[])
{
if (argc != 1)
{
std::cerr << "Takes no parameters, but " << argc << "parameters given" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the test has no parameters, preferably make it a GoogleTest. GoogleTest unit tests are typically more "to the point", avoiding unnecessary verbosity.

EdgeInfo back = curr;
while (!(rawEdges[i].empty()))
auto maxStop = rawEdges[i].size();
while (!(rawEdges[i].empty()) && (maxStop != 0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that the check !(rawEdges[i].empty()) is redundant now? I mean, could it just say:

    while ( maxStop > 0 )

If so, I would prefer such a simplification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't simply be a for loop?

    for ( auto maxStop = rawEdges[i].size(); maxStop != 0; --maxStop ) 

Maybe then rename maxStop to j:

    for ( auto j = rawEdges[i].size(); j != 0; --j ) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Segmentation Issues affecting the Segmentation module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants