-
-
Notifications
You must be signed in to change notification settings - Fork 706
BUG: fix an infinite loop in itk::VoronoiDiagram2DGenerator #5400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
BUG: fix an infinite loop in itk::VoronoiDiagram2DGenerator #5400
Conversation
There was a problem hiding this 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.
Don't know if you want a regression test, and if your framework can handle "infinite looping" type failures. |
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. |
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. |
f5ff22b
to
62457de
Compare
There was a problem hiding this 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.
Nah, the full "http://..." link is probably what triggers it, GitHub prettifies it on display. |
62457de
to
288b65e
Compare
EdgeInfo front = curr; | ||
EdgeInfo back = curr; | ||
while (!(rawEdges[i].empty())) | ||
auto maxStop = static_cast<int>(rawEdges[i].size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a static_cast to a signed int here? What if there are more edges than will fit in the positive range of an integer?
I think maxStop could just be the same type as size() ( likely size_t ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The > 0
condition can't work on an unsigned. It'd make sense to cast it to a bigger type or use size_t
and check for != SIZE_MAX
, though. Which one do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ILoveGoulash Thank you for your pull request. 👍 Specifically regarding your comment here, I think you're mistaken! When u
is an unsigned number, the condition u > 0
just works fine! (It is equivalent to the condition u != 0
.)
HTH, Niels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll try to find the time tomorrow to fix that.
@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. |
288b65e
to
380c33d
Compare
Should be okay now. |
380c33d
to
8f868e4
Compare
The loop exit condition was present in the code, but never wired and removed via InsightSoftwareConsortium@cd97879 Fixes InsightSoftwareConsortium#4386
8f868e4
to
c6ccef6
Compare
@ILoveGoulash I rebased and removed the merge conflict, then updated the commit message for the regression test to be more descriptive. |
Thanks! |
Tests and resolves InsightSoftwareConsortium#4386 where specific values caused deadlocks.
c6ccef6
to
cec88e2
Compare
The loop exit condition was present in the code, but never wired and removed via cd97879
PR Checklist
Refer to the ITK Software Guide for
further development details if necessary.