Skip to content

[Bug] SetupAxisLimits causes OOM #709

Description

@cpizano

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).

Metadata

Metadata

Assignees

Labels

prio:highHigh prioritystatus:todoTask identified but not startedtype:fixSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions