Crash in GetMousePosOnOpeningCurrentPopup #9551

Closed
opened 2026-09-21 19:50:38 +00:00 by jkunstwald · 1 comment
jkunstwald commented 2026-09-21 19:50:38 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

v1.92.9b, docking

Back-ends:

Custom

Compiler, OS:

Windows 11, MSVC

Full config/build information:

Dear ImGui 1.92.9b (19291)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 4, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: IMGUI_DISABLE_DEFAULT_ALLOCATORS
define: _WIN32
define: _WIN64
define: _MSC_VER=1938
define: _MSVC_LANG=201703
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: ImGui_Impl32_AVEX
io.BackendRendererName: ImGui_ImplPHI_AVEX
io.ConfigFlags: 0x00000481
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigDockingWithShift
io.ConfigDockingTransparentPayload
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00003C1E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 HasParentViewport
 RendererHasVtxOffset
 RendererHasTextures
 RendererHasViewports
--------------------------------
io.Fonts: 4 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: FreeType (2.10.4; 2.10.4)
io.DisplaySize: 1823.00,1391.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 4.00,4.00
style.WindowBorderSize: 0.00
style.FramePadding: 4.00,4.00
style.FrameRounding: 0.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 4.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

Crash in GetMousePosOnOpeningCurrentPopup

  • I'm calling GetMousePosOnOpeningCurrentPopup() from within a popup. The two previous imgui calls are
    • BeginPopupEx(...)
    • Selectable(...)
  • The application crashes because an ImVector is accessed OOB

It seems to be a simple typo but I wanted to double-check whether I'm missing something:
That function tests whether g.BeginPopupStack is nonempty, but proceeds to access g.OpenPopupStack. In my case, BeginPopupStack has size 1, but OpenPopupStack has size 0. (Both have capacity 8).

I assume the fix is to simply access BeginPopupStack in all three places.
Thanks in advance!

Screenshots/Video:

The screen right before the crash:
Image

The crash in VS, showing how OpenPopupStack is empty and accessed at idx 0 regardless:
Image

Minimal, Complete and Verifiable Example code:

### Version/Branch of Dear ImGui: v1.92.9b, docking ### Back-ends: Custom ### Compiler, OS: Windows 11, MSVC ### Full config/build information: ```cpp Dear ImGui 1.92.9b (19291) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 4, sizeof(ImDrawVert): 20 define: __cplusplus=199711 define: IMGUI_DISABLE_DEFAULT_ALLOCATORS define: _WIN32 define: _WIN64 define: _MSC_VER=1938 define: _MSVC_LANG=201703 define: IMGUI_HAS_VIEWPORT define: IMGUI_HAS_DOCK IM_ASSERT: runs expression: OK. expand size: OK -------------------------------- io.BackendPlatformName: ImGui_Impl32_AVEX io.BackendRendererName: ImGui_ImplPHI_AVEX io.ConfigFlags: 0x00000481 NavEnableKeyboard DockingEnable ViewportsEnable io.ConfigViewportsNoDecoration io.ConfigViewportsNoDefaultParent io.ConfigDockingWithShift io.ConfigDockingTransparentPayload io.ConfigNavCaptureKeyboard io.ConfigInputTextCursorBlink io.ConfigWindowsResizeFromEdges io.ConfigMemoryCompactTimer = 60.0 io.BackendFlags: 0x00003C1E HasMouseCursors HasSetMousePos PlatformHasViewports HasMouseHoveredViewport HasParentViewport RendererHasVtxOffset RendererHasTextures RendererHasViewports -------------------------------- io.Fonts: 4 fonts, Flags: 0x00000000, TexSize: 512,128 io.Fonts->FontLoaderName: FreeType (2.10.4; 2.10.4) io.DisplaySize: 1823.00,1391.00 io.DisplayFramebufferScale: 1.00,1.00 -------------------------------- style.WindowPadding: 4.00,4.00 style.WindowBorderSize: 0.00 style.FramePadding: 4.00,4.00 style.FrameRounding: 0.00 style.FrameBorderSize: 1.00 style.ItemSpacing: 4.00,4.00 style.ItemInnerSpacing: 4.00,4.00 ``` ### Details: **Crash in GetMousePosOnOpeningCurrentPopup** - I'm calling `GetMousePosOnOpeningCurrentPopup()` from within a popup. The two previous imgui calls are - `BeginPopupEx(...)` - `Selectable(...)` - The application crashes because an ImVector is accessed OOB It seems to be a simple typo but I wanted to double-check whether I'm missing something: That function tests whether `g.BeginPopupStack` is nonempty, but proceeds to access `g.OpenPopupStack`. In my case, BeginPopupStack has size 1, but **Open**PopupStack has size 0. (Both have capacity 8). I assume the fix is to simply access `BeginPopupStack` in all three places. Thanks in advance! ### Screenshots/Video: The screen right before the crash: <img width="332" height="218" alt="Image" src="https://github.com/user-attachments/assets/3c869b3d-c470-4808-a1b0-83fa8a6507e8" /> The crash in VS, showing how OpenPopupStack is empty and accessed at idx 0 regardless: <img width="807" height="174" alt="Image" src="https://github.com/user-attachments/assets/5c6393fb-2fd4-49df-b364-3f9a30b01488" /> ### Minimal, Complete and Verifiable Example code:
ocornut commented 2026-09-21 21:28:32 +00:00 (Migrated from github.com)

Sorry it seems like GitHub is facing a wave of spams. I blocked them and enabled some temporary interaction limits.

Sorry it seems like GitHub is facing a wave of spams. I blocked them and enabled some temporary interaction limits.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#9551
No description provided.