Repository navigation
Conversation
Under concurrent ctest -j load on ARM64, a unit-test process can wedge forever
after main returns. Full-memory dumps of the wedged *_ut_exe_ebs.exe show
thread 0 (single-threaded post-main) stuck in NtQueryVirtualMemory <-
KERNELBASE!QueryVirtualMemoryInformation, reached from VLD's leak report that
runs under the loader lock at DLL_PROCESS_DETACH:
~VisualLeakDetector -> leak report (pre-warm GetLeaksCount + ReportLeaks)
-> GetCallingModule() -> QueryVirtualMemoryInformation -> NtQueryVirtualMemory
On ARM64 that per-address memory-region query intermittently livelocks under
the loader lock at process exit (aka.ms/AA10dvw4); on x64 it does not. It can
strike ANY VLD-linked exe under concurrent -j load, not a specific test. The
existing Arm64TeardownReportScope only suppressed dbghelp symbolization, not the
GetCallingModule -> QueryVirtualMemoryInformation path that actually wedges.
GetCallingModule() is reached during teardown from two kinds of caller:
(a) VLD's allocation hooks -> CaptureContext::~CaptureContext ->
IsExcludedModule() (for the report's own transient allocations), and
(b) CallStack::resolve()/resolveFunction() -> GetCallingModule() per frame,
driven by the pre-warm's call-stack resolution.
Fix (ARM64-only, non-weakening), all in src/vld.cpp + src/utility.cpp:
1. GetCallingModule(): during the ARM64 teardown report, look the module up via
the loader (GetModuleHandleExW FROM_ADDRESS) instead of
QueryVirtualMemoryInformation/VirtualQuery. The loader walk cannot reach
NtQueryVirtualMemory and is safe under the (already-held) loader lock. For a
code address this returns the same module base; for a non-module address it
returns NULL, which every caller already treats as 'not a tracked module'.
Gated by a new broad g_arm64InTeardown flag set BEFORE the pre-warm (separate
from g_arm64InTeardownReport, which must stay off during the pre-warm so
suppression names can still be resolved). This covers caller (b) and (a).
2. ~CaptureContext(): when leak detection is disabled on this thread or the
thread holds the DbgHelp lock, skip IsExcludedModule() (the inner heap hooks
already recorded no block, so nothing is mapped either way). Mirrors the
existing _HeapAlloc guard; removes redundant GetCallingModule calls -- caller (a).
3. ~VisualLeakDetector(): disable leak detection on the teardown thread across
the pre-warm + ReportLeaks(), restoring it before TLS is torn down, so the
report's own transient allocations are not tracked.
The reported leak set is unchanged (guarded allocations were never going to be
mapped; the loader lookup returns the same module base for code addresses).
x64/x86 behavior is untouched. Verified on ARM64 (Cobalt) hardware by looping
the gate's full unit-test ctest -j16 suite: unfixed wedges on pass 1, fixed
stays green.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
anporumb
commented
Aug 13, 2026
| extern VisualLeakDetector g_vld; | ||
| extern ImageDirectoryEntries g_Ide; | ||
| #if defined(_M_ARM64) | ||
| extern "C" bool VldArm64InTeardown(void); |
Author
There was a problem hiding this 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.
No description provided.