Demo: assertion triggered when clicking two buttons that set ConfigColorEditFlags in an invalid state #9640

Closed
opened 2026-11-27 23:26:49 +00:00 by sequpt · 0 comments
sequpt commented 2026-11-27 23:26:49 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version 1.93.1/master

Back-ends:

imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Linux + GCC 14

Full config/build information:

Dear ImGui 1.93.1 (19310)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=14
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_sdl3 (3.2.26; 3.2.26) (x11)
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000001E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
 RendererHasTextures
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1280.00,800.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 3.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Details:

In the Widgets -> Color/Picker Widgets -> Color picker part of the demo, clicking either the Overwrite default: Uint8 + HSV + Hue Bar or Overwrite default: Float + HDR + Hue Wheel button triggers an assert.

The first button triggers imgui.cpp:11263: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_)' failed.
The second button triggers imgui.cpp:11260: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DisplayMask_)' failed.

I'm not familiar at all with imgui code but after some digging this is what I've found:

ConfigColorEditFlags needs an input bit and a display bit but the first button sets only the display bit and the second button sets none of them.

ocornut/imgui@1ddd7ee13d/imgui_demo.cpp (L1365-L1368)

It seems the bug was introduced in ocornut/imgui@0e479b9554 when ImGui::SetColorEditOptions() was replaced with ImGui::GetStyle().ColorEditFlags = (which was then changed to ImGui::GetIO().ConfigColorEditFlags = through commit 9f7d8086fe and aca69173df).

The problem is that ImGui::SetColorEditOptions() was setting default bits if they were missing but now that ConfigColorEditFlags is set directly it remains in an invalid state and triggers the assertions.

It seems that adding the missing bits like this:

if (ImGui::Button("Overwrite default: Uint8 + HSV + Hue Bar"))
            ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar;
if (ImGui::Button("Overwrite default: Float + HDR + Hue Wheel"))
            ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Float | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel;

prevents the assertions and shows the same visual behavior as the one in the commit before the bug was introduced.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

### Version/Branch of Dear ImGui: Version 1.93.1/master ### Back-ends: imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp ### Compiler, OS: Linux + GCC 14 ### Full config/build information: ```cpp Dear ImGui 1.93.1 (19310) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20 define: __cplusplus=201103 define: __linux__ define: __GNUC__=14 IM_ASSERT: runs expression: OK. expand size: OK -------------------------------- io.BackendPlatformName: imgui_impl_sdl3 (3.2.26; 3.2.26) (x11) io.BackendRendererName: imgui_impl_opengl3 io.ConfigFlags: 0x00000003 NavEnableKeyboard NavEnableGamepad io.ConfigNavCaptureKeyboard io.ConfigInputTextCursorBlink io.ConfigWindowsResizeFromEdges io.ConfigMemoryCompactTimer = 60.0 io.BackendFlags: 0x0000001E HasMouseCursors HasSetMousePos RendererHasVtxOffset RendererHasTextures -------------------------------- io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128 io.Fonts->FontLoaderName: stb_truetype io.DisplaySize: 1280.00,800.00 io.DisplayFramebufferScale: 1.00,1.00 -------------------------------- style.WindowPadding: 8.00,8.00 style.WindowBorderSize: 1.00 style.FramePadding: 4.00,3.00 style.FrameRounding: 3.00 style.FrameBorderSize: 0.00 style.ItemSpacing: 8.00,4.00 style.ItemInnerSpacing: 4.00,4.00 ``` ### Details: In the `Widgets` -> `Color/Picker Widgets` -> `Color picker` part of the [demo](https://github.com/ocornut/imgui/blob/1ddd7ee13d12cf2663ca175141e38398fab39711/imgui_demo.cpp), clicking either the `Overwrite default: Uint8 + HSV + Hue Bar` or `Overwrite default: Float + HDR + Hue Wheel` button triggers an assert. The first button triggers ``imgui.cpp:11263: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_InputMask_)' failed.`` The second button triggers ``imgui.cpp:11260: void ImGui::ErrorCheckNewFrameSanityChecks(): Assertion `ImIsPowerOfTwo(g.IO.ConfigColorEditFlags & ImGuiColorEditFlags_DisplayMask_)' failed.`` I'm not familiar at all with imgui code but after some digging this is what I've found: `ConfigColorEditFlags` needs an input bit and a display bit but the first button sets only the display bit and the second button sets none of them. https://github.com/ocornut/imgui/blob/1ddd7ee13d12cf2663ca175141e38398fab39711/imgui_demo.cpp#L1365-L1368 It seems the bug was introduced in https://github.com/ocornut/imgui/commit/0e479b95543b736143ebc815fc727ba8c035f5c2 when `ImGui::SetColorEditOptions()` was replaced with `ImGui::GetStyle().ColorEditFlags =` (which was then changed to `ImGui::GetIO().ConfigColorEditFlags =` through commit 9f7d8086fe653cf12b8c83961effd8e53a88d4ad and aca69173dfaf3c54c02a5f699ca4cd1211154446). The problem is that `ImGui::SetColorEditOptions()` was setting default bits if they were missing but now that `ConfigColorEditFlags` is set directly it remains in an invalid state and triggers the assertions. It seems that adding the missing bits like this: ```cpp if (ImGui::Button("Overwrite default: Uint8 + HSV + Hue Bar")) ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar; if (ImGui::Button("Overwrite default: Float + HDR + Hue Wheel")) ImGui::GetIO().ConfigColorEditFlags = ImGuiColorEditFlags_Float | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel; ``` prevents the assertions and shows the same visual behavior as the one in the commit before the bug was introduced. ### Screenshots/Video: _No response_ ### Minimal, Complete and Verifiable Example code:
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#9640
No description provided.