Conversation
Keep TLS trivial and let each dispatch scope own the pending-list snapshot so unused attaching threads allocate nothing and completed dispatches retain no thread-owned storage. Preserve nested listener and release semantics. Add listener coverage and an SDK-only unload regression that checks zero outstanding blocks and bytes with seven worker threads still alive. Files changed: - lib/callbacks/DebugSource.cpp - lib/callbacks/DebugSourceInternal.hpp - tests/CMakeLists.txt - tests/unittests/DebugEventSourceTests.cpp - tests/dll-unload/CMakeLists.txt - tests/dll-unload/debug-listener-unload-module.cpp - tests/dll-unload/debug-listener-unload-test.cpp - tests/dll-unload/README.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e3876793-eab3-449a-b32b-5a983d24a6c3
Replace the WinRT activation path that can fail or hang after final apartment teardown. Resolve modern IP Helper APIs dynamically and balance native NLM subscriptions in an SDK-owned STA on older supported Windows. Drain dispatched callbacks through completion, retain the embedding DLL only until callback return, and preserve drain state for reentrant/concurrent stop and restart. Keep cost refreshes on the backend's owning thread. Files changed: - lib/pal/desktop/NetworkDetector.cpp - lib/pal/desktop/NetworkDetector.hpp - tests/common/network-detector-test-access.hpp - tests/unittests/NetworkDetectorTests.cpp - tests/dll-unload/CMakeLists.txt - tests/dll-unload/debug-listener-unload-module.cpp - tests/dll-unload/debug-listener-unload-test.cpp - tests/dll-unload/network-detector-reload-test.cpp - tests/dll-unload/README.md - docs/building-custom-SKU.md - .github/workflows/memory-leak-analysis.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e3876793-eab3-449a-b32b-5a983d24a6c3
Before the WinRT-only detector change, NLM connectivity monitoring could run when its optional cost interface was unavailable. Activate INetworkListManager first and keep Unknown cost after logged query failures, including on Server. Preserve the original three NLM event families instead of requiring the newly added cost-specific events. Let the private non-agile sink's STA complete COM rundown after an explicit disconnect failure instead of terminating the host. Cover no-cost operation, cost-query errors, partial subscriptions and apartment rundown in unit tests and the zero-allocation DLL unload/reload harness. Files changed: - lib/pal/desktop/NetworkDetector.cpp - lib/pal/desktop/NetworkDetector.hpp - tests/common/network-detector-test-access.hpp - tests/unittests/NetworkDetectorTests.cpp - tests/dll-unload/CMakeLists.txt - tests/dll-unload/debug-listener-unload-module.cpp - tests/dll-unload/debug-listener-unload-test.cpp - tests/dll-unload/network-detector-reload-test.cpp - tests/dll-unload/README.md - docs/building-custom-SKU.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e3876793-eab3-449a-b32b-5a983d24a6c3
Keep IP Helper detection where both runtime APIs are available. On older Windows, retain unknown network cost without starting listener resources, rather than activating Network List Manager and its internal COM threads. Replace legacy coverage with missing-API and native failure/retry tests. Require zero actual and possible leaks in the isolated detector CI scan and extend the no-NLM module gate to the full unit suite. Files changed: - lib/pal/desktop/NetworkDetector.cpp - lib/pal/desktop/NetworkDetector.hpp - tests/common/network-detector-test-access.hpp - tests/unittests/NetworkDetectorTests.cpp - tests/dll-unload/debug-listener-unload-module.cpp - tests/dll-unload/debug-listener-unload-test.cpp - tests/dll-unload/network-detector-reload-test.cpp - tests/dll-unload/CMakeLists.txt - tests/dll-unload/README.md - docs/building-custom-SKU.md - .github/workflows/memory-leak-analysis.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e3876793-eab3-449a-b32b-5a983d24a6c3
Restore the optional-cost NLM backend so older Windows keeps its original connectivity coverage. Unload-sensitive consumers can avoid that COM path by disabling network detection before SDK initialization. Exercise the actual disabled configuration through network information creation, seven-live-thread DLL unload and five-cycle reload. Keep a strict zero-leak CI gate for modern and disabled detection without pretending the restored COM backend or broader SDK is leak-free. Describe actual GitHub Actions coverage rather than treating cross-builds as runtime testing on every supported target OS. Files changed: - README.md - .github/workflows/memory-leak-analysis.yml - docs/building-custom-SKU.md - lib/pal/desktop/NetworkDetector.cpp - lib/pal/desktop/NetworkDetector.hpp - tests/common/network-detector-test-access.hpp - tests/unittests/NetworkDetectorTests.cpp - tests/dll-unload/CMakeLists.txt - tests/dll-unload/README.md - tests/dll-unload/debug-listener-unload-module.cpp - tests/dll-unload/debug-listener-unload-test.cpp - tests/dll-unload/network-detector-reload-test.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e3876793-eab3-449a-b32b-5a983d24a6c3
This branch has not been deployed
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
Fix Debug Windows leaks when a DLL embedding the SDK is unloaded with attaching
threads still alive, and make Windows network detection survive repeated DLL
loads without requiring the host to keep a COM MTA alive.
Pending listeners
PendingListenersScope-owned storage.registrations, removal, exception unwinding, and reentrant release callbacks.
Network detector
The SDK-only reproducer failed on the second load with the former WinRT
activation path. Keeping a host MTA alive isolated the dependency but is not
part of this fix.
on Windows 10 version 2004/build 19041 and later, without WinRT or NLM.
connectivity hints are unavailable. Own its STA, interfaces and the original
three event families entirely inside the SDK, without a host-owned MTA.
Query cost support optionally; unavailable or failed cost queries retain
unknown cost while base connectivity monitoring continues.
Explicit COM disconnection failure logs an error but does not terminate the
host.
CFG_BOOL_ENABLE_NET_DETECT = falsebefore SDKinitialization to avoid constructing either detector backend. Preserve
existing disabled-detection cost behavior. Add unit and actual DLL
unload/reload regressions for this configuration.
across restart.
stops after a reentrant stop. Restart also drains the previous dispatch.
Balance each callback's temporary DLL reference with
FreeLibraryWhenCallbackReturns; do not permanently retain the DLL.callbacks into unloaded SDK code is unsafe.
actual and possible leaks in an isolated modern/disabled detector scan.
Enforce no
netprofm.dllloads for those paths and functional/sampleproduction scenarios. The full unit suite deliberately exercises COM.
The modern backend reports aggregate connectivity hints rather than only the
WinRT Internet connection profile. These hints do not expose WinRT's separate
background-data restriction flag. Roaming and approaching/exceeded data limits
remain restrictive.
The user chose to retain older-Windows compatibility and disable detection
in unload-sensitive consumers instead. A prior forced-NLM scan reported a
528-byte COM allocation on an OS notification thread. Its precise root cause
and per-cycle growth remain unestablished; retaining COM is not a claim that
this native-heap finding has been fixed. The original Debug listener TLS
allocation fix remains intact.
Update the README Target Platforms CI column to distinguish native runtime
tests, cross-builds, API-floor checks and OS versions without GitHub runners.
Validation
The Windows hosts do not link the SDK. They embed the static SDK in a Debug DLL,
require the shared Debug CRT/default Debug STL iterator checking, verify actual
DLL unloading, and count outstanding normal/client CRT allocations.
tests pass, covering runtime disablement, legacy/no-cost capabilities,
failed subscription/retry, repeated
start/read/stop, queued refresh races, concurrent/reentrant stop, callback drain,
restart, and cost reads across listener generations.
read/stop/unload cycles, with 0 blocks / 0 bytes per cycle, while the host
COM apartment remains uninitialized. All seven worker threads are confirmed
alive at the seven live-thread unload checkpoints.
DebugEventSourceTests.*pass.suites. The feature-disabled module reports explicit skip code 77 for network
cases; its idle/dispatch cases still pass with zero blocks/bytes.
misspellv0.3.4 andgit diff --checkpass.APIs directly. The network detector no longer activates WinRT.
The full functional suite passes 101/105, with four sanitizer/privacy
concern-count assertions reporting one extra event. All 13 sanitizer
functional tests pass in isolation, indicating sequence-dependent test
state; this does not turn the failed full-suite run into a pass.
and 86/86 functional assertions pass, but both processes exit 1
because leak checking fails. Units report 219,952 bytes in 174
allocations; functional tests report 17,298 bytes in 105 allocations.
A positive control established working leak detection. No negative filters
or leak suppressions were added.
the unit suite leaves caller-owned HTTP requests unfreed, including a
204,800-byte request body. Functional stacks include
DefaultDataViewer::SendPacketandLiveEventInspector::InspectRecord.DataViewer does not release requests borrowed by the current SDK transports
or delete the responses transferred to its callback by the public contract.
Its mocks also have incorrect ownership, including wrapping the borrowed
callback in an owning
shared_ptr. These module/test defects are not fixedby the listener TLS or Windows network-lifecycle changes in this PR.
completed successfully for restoration revision
2bfc8fb5. The strictmodern/runtime-disabled detector scan has zero actual and possible leaks,
and the no-NLM production-path gate passes. Its unit scans remain nonzero:
These CI configurations do not exercise all the optional modules included in
the local all-module runs above. Their unchanged unit baseline checks emit
warnings rather than fail CI, so workflow success is not whole-SDK leak
freedom. The restored Windows unit report again contains the 528-byte
NETPROFM/COM finding on an OS WNF notification thread. Its root cause and
per-cycle growth are still unestablished. No new leak baselines or timing
exclusions were introduced.
All six current-head Win32/x64 Debug/Release WinHTTP/WinInet test jobs and the
Windows public-header/API-floor gate pass.
Coverage: IP Helper connectivity hints are used where available (Windows
10 2004/build 19041 and corresponding Server releases). The COM fallback
preserves base NLM coverage without requiring client-only cost interfaces.
This does not change the whole SDK's OS support policy or compiler/runtime
requirements. Runtime disablement and custom-SKU exclusion remain available.
Limits: Forced legacy execution on the current Windows host is not actual
older-OS execution. These are SDK-only embedding tests, not an ORT
Windows consumer build: the inspected ORT checkout uses ETW on Windows and
excludes 1DS from its standard Windows build. The Debug CRT checks are not a
claim of zero allocations in every OS/native heap. The CI-pinned Dr. Memory
tool could not launch even an SDK-independent target locally (0xc06d007f);
native-heap results above come from the supported Windows CI host.
Android native ASan detects a known memory-error control, but its runtime
forces leak detection off and does not report a known-leak control.
Standalone LSan fails to link with both installed NDK versions. The complete
Android native unit binary also has an existing Room/SQLite backend linkage
mismatch. The native functional run without a Java VM encounters configuration
failures and a subsequent sanitizer error; its isolated bad-network test
passes. None of these Android results establishes leak freedom.
The workflow's pre-existing timing-sensitive exclusions are unchanged, and
no new exclusions or relaxed leak baselines have been added.
Based on Microsoft
mainat3886eda702c3dd986bf47160a6e91b91f19114ae.