[Bug] SetupAxisLimits causes OOM
- Dominant language
- C++
- Stars
- 6.2k
- Forks
- 693
- PR merge metrics
- No merged PRs in 30d
Description
ImPlot 0.17 against Dear Imgui 1.92.1 (docking branch)
### Compiler, OS:
clang, Linux 7.0.9
### Details:
`Locator_Default` never terminates on a degenerate axis range when the plot is wide, allocating until OOM.
When an axis range is zero-width (e.g. `SetupAxisLimits(min, max)` with `min == max`, which ImPlotAxis constrains to Max = Min + DBL_EPSILON) and the plot is wide enough that nMajor >= 5 (~1800+ pixels), the computed tick interval `NiceNum(NiceNum(range.Size()*0.99, false)/(nMajor-1), true)` falls below half an ULP of the tick values.
So, `for (double major = graphmin; major < graphmax + 0.5*interval; major += interval)` the addition rounds back to the same double, the loop never advances, and it pushes ticks into the ticker forever.
Observed:
```
range [1.0, 1.0000000000000002]
pixels = 1841
nMajor = 5
interval = 1e-16 vs ULP(1.0) = 2.2e-16
```
Causes 130 M ticks and ~40 GB allocated before the OOM killer intervened).
A minimal fix is to break out of the loop when major + interval == major (or clamp the interval to at least one ULP of the range endpoints).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.