`move_item` with the `before` argument can crash DPG if abused
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start with the minimal Python example and the move_item API paths for the before and parent arguments. Reproduce the crash by moving the drawing circle before the plot axis, then compare it with appending the circle to the plot. Done means an incompatible-slot move raises an exception like the incompatible-parent case instead of crashing.
Written by the indexing model from the issue text.
Description
Version of Dear PyGui
Version: 2.3
Operating System: Windows 10
My Issue/Question
While move_item now checks for parent/child compatibility, it does not check whether the item is being moved to an appropriate slot. As a result, before can be (ab)used to move an item to a slot where it does not belong, for example, move a drawing primitive from slot 2 to plot children' slot 1 (see the example below).
Notice that move_item(parent=...) does properly deduce the slot (can be tested with the "Move (append to plot)" button in the example).
To Reproduce
Steps to reproduce the behavior:
- Run the example
- Click "Move (before axis)"
- You'll get a segfault as the circle will be moved to immediate plot children slot 1 and treated as a mvPlotAxis.
Expected behavior
move_item must raise an exception the same way it does when it bumps into incompatible parent.
Screenshots/Video
None.
Standalone, minimal, complete and verifiable example
from math import sin
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title=f"Test - {dpg.get_dearpygui_version()}", width=900, height=900)
with dpg.window():
dpg.set_primary_window(dpg.last_item(), True)
x_data = [x for x in range(0, 200)]
y_data = [10*sin(x/10)+100 for x in x_data]
with dpg.plot(width=-1, height=300) as plot:
dpg.add_plot_axis(dpg.mvXAxis)
with dpg.plot_axis(dpg.mvYAxis) as axis:
series = dpg.add_line_series(x_data, y_data)
victim = dpg.draw_circle((100, 100), 50)
dpg.add_button(label="Move (before axis)", callback=lambda: dpg.move_item(victim, before=axis))
dpg.add_button(label="Move (append to plot)", callback=lambda: dpg.move_item(victim, parent=plot))
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.show_item_registry()
dpg.start_dearpygui()
dpg.destroy_context()
- Dominant language
- C++
- Stars
- 15.7k
- Forks
- 790
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from hoffstadt/DearPyGui
-
Plot series data silently truncated to float32 when passed as numpy array (should be float64/double)Openstate: pending type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
state: pending type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
state: pending type: improvement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
state: pending type: bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
state: pending type: improvement
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in hoffstadt/DearPyGui
Similar issues
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
bot-triaged module: correctness (silent) module: fft triage review
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
patrickjquinn/Marathon-Shell#84 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 1 day