Skip to content

fix: prevent infinite loop in Locator_Default for degenerate axis ranges - #206

Merged
brenocq merged 1 commit into
mainfrom
fix/zero-range-tick-loop
Oct 25, 2026
Merged

brenocq merged 1 commit into
mainfrom
fix/zero-range-tick-loop

Conversation

@brenocq

@brenocq brenocq commented Oct 25, 2026

Copy link
Copy Markdown
Owner

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 to Min + DBL_EPSILON, so the range.Min == range.Max early return in Locator_Default is not hit. The range then holds only a couple of representable doubles, the tick interval drops below half the gap between neighboring doubles, major += interval rounds back to major, 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).

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.
@brenocq brenocq added type:fix Something isn't working prio:high High priority status:review The task is under review labels Oct 25, 2026
@brenocq brenocq self-assigned this Oct 25, 2026
@brenocq
brenocq merged commit 897fe91 into main Oct 25, 2026
10 checks passed
@brenocq
brenocq deleted the fix/zero-range-tick-loop branch October 25, 2026 14:58
@github-actions github-actions Bot added status:done Task completed successfully and removed status:review The task is under review labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:high High priority status:done Task completed successfully type:fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant