Skip to content
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

Fix infinite while loop for unsigned int label query #4404

Merged
merged 4 commits into from
Oct 11, 2023
Merged

Conversation

jp-dark
Copy link
Contributor

@jp-dark jp-dark commented Oct 6, 2023

The ordered label reader had an infinite loop for dimension labels on unsigned integers when the lower bound of the desired result was zero.


TYPE: BUG
DESC: Fix bug in ordered label reader for unsigned integers

@jp-dark jp-dark requested a review from KiterLuc October 6, 2023 21:01
@KiterLuc
Copy link
Member

KiterLuc commented Oct 9, 2023

Thanks for the fix @jp-dark. Can we add a test for this case?

@jp-dark
Copy link
Contributor Author

jp-dark commented Oct 9, 2023

Thanks for the fix @jp-dark. Can we add a test for this case?

I added a test for this case and further modified the loop so if there is a different missing edge case, it will at least error out eventually.

@@ -638,7 +638,11 @@ IndexType OrderedDimLabelReader::search_for_range(

// Run a binary search.
Op cmp;
Copy link
Member

Choose a reason for hiding this comment

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

I wrapped the original loop with if (left_index != right_index) { and it seems to be fixing the added test case... Does it also fix your original case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should. The original case was the result of a typo in a Python examples: If the right side of the tile is 0 on an unsigned dimension, then subtracting 1 from the right side creates a very large number and the end condition is never met. This is only possible if the tile size is 1 (the typo).

@KiterLuc KiterLuc merged commit 33dd062 into dev Oct 11, 2023
53 checks passed
@KiterLuc KiterLuc deleted the jpd/label-fix branch October 11, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants