-
-
Notifications
You must be signed in to change notification settings - Fork 768
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.