Repository navigation
Conversation
ShowCursor was the only entry point not checking isContextInitialized; a disconnect path calling it after Shutdown() crashed on a null context. Shutdown() also cleared the flag after DestroyContext(); clear it first.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ImGUI::Wrapper::ShowCursor()was the only public entry point on the wrapperthat did not check
isContextInitializedbefore touching ImGui state. A clientteardown path (disconnect handling → release control locks →
ShowCursor(false))ran after
Wrapper::Shutdown()and dereferenced a destroyed ImGui context.Found while symbolizing a user-submitted crash dump from a Release build of a
UE 4.27.2 title on the D3D12 backend.
Crash signature
ImGui::GetIO()resolves toGImGui->IO. With a null context that isnullptr + offsetof(ImGuiContext, IO)=0x28(matchesrax), andImGuiIO::MouseDrawCursorat+0x50puts the store at0x78(matches thefaulting address).
rbx=0is thefalsebeing written.Release-only in practice:
ImGui::GetIO()normally carriesIM_ASSERT(GImGui != NULL), which/DNDEBUGremoves, degrading the guard intoa raw null dereference.
Two defects fixed
ShowCursornever checked the flag. Every other gated entry point(
Init,Shutdown,Render,OnDeviceLost,OnDeviceReset) does.Shutdown()clearedisContextInitializedafterDestroyContext().That left a window in which the flag claimed the context was live while the
backends were already shut down and the context destroyed — so the guard in
(1) alone would not cover a caller landing inside it. The flag is now cleared
up front, immediately after the early-out.
Investigation notes: GPU was ruled out, not a factor
Recording this so it is not re-chased. The reporting machine is a hybrid-graphics
laptop, and the crash context showed the title rendering on the integrated
GPU (
Misc.PrimaryGPUBrand= Intel iGPU; only the Intel D3D12 UMD was loaded inthe process, the NVIDIA D3D UMD never was) despite a discrete GPU being present.
That initially looked causal — a renderer hook failing to attach would leave
isContextInitialized == falseand reach the same defect. It was ruled out:control panel) did not stop the crash.
Inithad succeeded and the context genuinely existed.Conclusion: this is a teardown-ordering bug, not a renderer-init bug. The GPU
selection oddity is real but separate, and is being tracked downstream.
Secondary observation (not addressed here)
CMAKE_CXX_FLAGS_RELEASEis/O2 /Ob2 /DNDEBUGwith no/DEBUGat link, soRelease builds ship without a PDB and user crash dumps cannot be symbolized
without reproducing the exact toolchain. Adding
/Ziplus/DEBUG:FULL /OPT:REF /OPT:ICF /PDBALTPATH:%_PDB%was measured on a real buildof this framework to cost exactly one 4 KB page of
SizeOfImagewhile leaving.textbyte-identical./OPT:REF /OPT:ICFmust be explicit —/DEBUGsilentlydefaults them off, which would change code layout. Happy to open a separate PR
if that is wanted.
Testing
Not reproduced locally — the crash requires the teardown ordering seen on the
reporting machine. The fix was verified by inspection against the symbolized
stack, and the register arithmetic above accounts for the faulting address
exactly. No behavioural change when the context is live; when it is not,
ShowCursorbecomes a no-op, which is correct (no cursor to draw).Summary by CodeRabbit