Repository navigation
fix: prevent infinite loop in Locator_Default for degenerate axis ranges - #206
Merged
Merged
Conversation
SetupAxisLimits(v, v) makes the axis widen the range to Max = Min + DBL_EPSILON, so the range.Min == range.Max early return in Locator_Default misses it. The range then holds only a couple of representable doubles, and on a large plot the tick interval falls below half the gap between neighboring doubles, so `major += interval` rounds back to `major` and the tick loop never ends, eating memory. Clamp the interval to one ULP of the range magnitude, computed with nextafter. For ordinary ranges the clamp is far below the real interval and changes nothing. Mirrors epezent/implot#725.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
SetupAxisLimits(ImAxis3D_X, v, v)(or any equal min and max) freezes the app and its memory use keeps growing.Constrain()widens the range toMin + DBL_EPSILON, so therange.Min == range.Maxearly return inLocator_Defaultis not hit. The range then holds only a couple of representable doubles, the tick interval drops below half the gap between neighboring doubles,major += intervalrounds back tomajor, and the tick loop never ends.The interval is now clamped to one ULP of the range magnitude, computed with
nextafter. For ordinary ranges this is far below the real interval and changes nothing. Mirrors the same fix in ImPlot (epezent/implot#725).