mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-14 19:04:44 +00:00
ImDrawList::AddPolyline stack overflow on large polylines #5704
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#5704
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The AddPolyline() function uses alloca() for temporary variables even with very large polylines (tens of thousands to millions of segments). This can lead to stack overflows.
This is not a major blocker for my application, which will be using custom shaders for large graphs in the future. I tried to use ImDrawList as a temporary debug visualization and apparently it can't handle it :)
But there should be, at minimum, a better failure mode such as throwing an assertion or falling back to malloc()'d memory. And any hard limits on primitive count should be documented somewhere.
Now that we have access to a shared ImDrawListSharedData instance I think it would be reasonable to turn this into a reused ImVector and use reserve_discard(). I may investigate this.
Also note #1811 could still potentially apply but is a separate task.
Pushed this change
f2a522d, no notable change.I even forgot to use reserve_discard() (instead of
reserve()) when I took those number, so amortization will be faster.Note we do not have a policy for freeing that shared buffer, so if you throw a million points at it it won't be freed.
We could use a moving-average approximation (without storage) to shrink back