Null free segfault before renderer is initialized
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Domain
- computer-graphics, desktop
Research direction
Start with mvRawTexture::~mvRawTexture() in mvTextureItems.cpp and trace its unconditional FreeTexture(_texture) call into mvUtilities_linux.cpp, mvUtilities_win32.cpp, and mvUtilities_apple.mm. Run the minimal Python reproduction before viewport setup, then verify that deleting a raw texture before renderer initialization no longer segfaults and that cleanup remains safe when a texture was never created.
Written by the indexing model from the issue text.
Description
Version of Dear PyGui
Version: 1.11.1 (pip wheel), 2.1.0
Operating System: Ubuntu 24.04 (WSL2, Mesa llvmpipe)
My Issue/Question
Callling dpg.add_raw_texture before the viewport/renderer is initialized causes a hard crash when the texture item is destroyed. The raw texture’s destructor always calls FreeTexture, which forwards to glDeleteTextures. In this code path the OpenGL loader (gl3w) has not been initialized yet, so dlDeleteTextures is a null function pointer and the process segfaults. The crash happens even when the raw texture never created a GL texture (e.g. because we delete it immediately).
Relevant sources:
mvRawTexture::~mvRawTexture()in mvTextureItems.cpp (unconditionally callsFreeTexture(_texture))FreeTextureimplementations (mvUtilities_linux.cpp, mvUtilities_win32.cpp, mvUtilities_apple.mm) which unconditionally call the GL driver.
To Reproduce
- Start a fresh Python session with Dear PyGui 1.11.1.
- Run the minimal script below (note there is no viewport setup yet).
- Python terminates with SIGSEGV inside
_dearpygui.so→FreeTexture→glDeleteTextures.
Expected behavior
Destroying a raw texture before the viewport/renderer is available should be a no-op, not a hard crash. Dear PyGui should either defer GL cleanup until the context exists or skip the glDeleteTextures call when _texture is null/uninitialized.
Screenshots/Video
Standalone, minimal, complete and verifiable example
import numpy as np
import dearpygui.dearpygui as dpg
dpg.create_context()
with dpg.texture_registry():
data = np.zeros((4,), dtype=np.float32)
tex_id = dpg.add_raw_texture(1, 1, data)
dpg.delete_item(tex_id) # <- segfault inside FreeTexture/glDeleteTextures
print("unreachable")
But any solution that avoids calling into GL before the loader/context is ready would work. Let me know if you need additional traces or testing on other platforms.
- 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