Repository navigation
Fix 1DS telemetry deadlock during Windows process termination - #33291
Merged
Jiajia Qin (qjia7) merged 4 commits intoOct 17, 2026
Merged
Conversation
Skip uploader teardown before acquiring telemetry locks when Windows is detaching DLLs for process termination. WinHTTP callbacks and worker threads are already gone at that point, so draining them can wait forever. Keep normal object destruction and explicit DLL unload cleanup. Validated against captured native hang stacks and identical machine code at all resolved frames. A pending-uploader fault injection hangs the unchanged runtime and exits in 20 of 20 fixed trials. Both WebGPU modes completed 1024-prompt, 32-output-token native profiles with LoRA on and off; explicit unload also passed.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The shutdown-specific deadlock fix lacks committed automated regression coverage.
1 open finding
What changed in this PR
Prevents Windows process termination from deadlocking during 1DS telemetry teardown.
Changes:
- Detects Windows DLL shutdown via
RtlDllShutdownInProgress. - Skips unsafe uploader teardown during process exit.
- Preserves normal destruction and explicit DLL-unload cleanup.
| File | Description |
|---|---|
onnxruntime/core/platform/windows/telemetry_1ds.cc |
Implements shutdown-state detection. |
onnxruntime/core/platform/telemetry_1ds.cc |
Bypasses teardown during Windows shutdown. |
onnxruntime/core/platform/telemetry_1ds_platform.h |
Declares the Windows helper. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Jiajia Qin (qjia7)
marked this pull request as ready for review
October 12, 2026 08:51
Jiajia Qin (qjia7)
requested review from
Baiju Meswani (baijumeswani) and
Edward Chen (edgchen1)
October 13, 2026 02:52
Edward Chen (edgchen1)
approved these changes
Oct 16, 2026
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.

Description
Native inference can finish successfully, write its profiling output, and then hang indefinitely while Windows terminates the process. Skip 1DS uploader teardown in
OneDsTelemetry::~OneDsTelemetrywhen Windows DLL shutdown is in progress, before acquiring telemetry locks.The Windows helper resolves
RtlDllShutdownInProgressfrom the already loadedntdll.dll. This process-wide check also works for telemetry compiled into an EP plugin DLL. Normal object destruction and explicitFreeLibraryretain the existing cleanup path; non-Windows behavior is unchanged. Pending telemetry is not flushed during process termination.Motivation and Context
Two captured native benchmark hangs had only the terminating thread remaining, with this shutdown stack:
Windows terminates the other threads before calling DLL process-detach destructors. The uploader can therefore wait forever for WinHTTP callbacks that can no longer run; a telemetry lock may also be held by a terminated thread. Checking shutdown state before taking locks avoids both waits. Resolved ORT/SDK frames were verified against identical machine code in a build with symbols.
Regression Coverage
Three committed Windows CTest cases load a fixture DLL linked to the production
onnxruntime_commontelemetry implementation. A test peer injects a mock log manager with network telemetry disabled; no model, GPU, or symbol-address patching is required.onnxruntime_telemetry_process_exit_test: callsExitProcesswith a pending mock callback and verifies that the real DLL-owned telemetry destructor skips uploader cleanup.onnxruntime_telemetry_normal_destruction_test: destroys the object before DLL unload and verifies oneFlush, oneFlushAndTeardown, and cleared shared state.onnxruntime_telemetry_explicit_unload_test: verifies the same cleanup duringFreeLibrary.The parent requires both a successful child exit and an inherited event signaled only after teardown assertions pass. Each child has a 10-second timeout, with a 15-second CTest limit. The mock drain itself is bounded to two seconds so a regressed shutdown cannot strand a child inside DLL teardown.
Run from the CMake build directory after building
onnxruntime_telemetry_shutdown_test:Validation
lintrunner -aandgit diff --checkpassed.The committed lifecycle tests use a mock uploader; they do not cover real pending-upload unload stress. The benchmark executable, GenAI DLL, model graph, configuration, and adapter were unchanged during runtime validation.