Skip to content

Commit fa09281

Browse files
bmehta001Copilot
andcommitted
Fix network shutdown and leak regression gaps
Serialize WinRT status callbacks through the listener queue so Stop joins all event delivery, and replace timeout-based detachment with an explicit ready/failed startup state. Honor IConnectionCost2 background restrictions, schedule weekly analysis, and compare all leak metrics with the reviewed cross-platform baseline using non-blocking warnings. Files changed: - .github/memory-leak-baseline.csv - .github/scripts/run-drmemory.ps1 - .github/workflows/memory-leak-analysis.yml - lib/pal/desktop/NetworkDetector.cpp - lib/pal/desktop/NetworkDetector.hpp - tests/unittests/NetworkDetectorTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ce3e63c commit fa09281

6 files changed

Lines changed: 238 additions & 94 deletions

File tree

‎.github/memory-leak-baseline.csv‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Platform,Scenario,UniqueLeaks,TotalLeaks,LeakBytes,UniquePossibleLeaks,TotalPossibleLeaks,PossibleLeakBytes,UniqueReachable,TotalReachable,ReachableBytes
2+
Windows,unit-tests,10,113,4256,14,15,7206,467,644,227717
3+
Windows,functional-tests,7,382,14072,7,3994,1038248411,1722,2823,725167
4+
Windows,sample-cpp-mini,0,0,0,0,0,0,973,1795,411008
5+
Linux,unit-tests,10,127,3730,5,7,3452,8,8,77045
6+
Linux,functional-tests,3,156,4694,1,1,4104,360,643,279619
7+
Linux,sample-cpp-mini,1,2,32,0,0,0,15,23,81130

‎.github/scripts/run-drmemory.ps1‎

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ param(
1616
[ValidateNotNullOrEmpty()]
1717
[string]$TargetPath,
1818

19-
[string[]]$TargetArguments = @()
19+
[string[]]$TargetArguments = @(),
20+
21+
[string]$BaselinePath
2022
)
2123

2224
Set-StrictMode -Version Latest
@@ -100,10 +102,50 @@ else {
100102
}
101103
$summaries | Export-Csv -LiteralPath $summaryPath -NoTypeInformation
102104

105+
$baselineStatus = "Not compared"
106+
if ($BaselinePath) {
107+
$resolvedBaselinePath = (Resolve-Path -LiteralPath $BaselinePath).Path
108+
$baselineRows = @(Import-Csv -LiteralPath $resolvedBaselinePath | Where-Object {
109+
$_.Platform -eq $summary.Platform -and $_.Scenario -eq $summary.Scenario
110+
})
111+
if ($baselineRows.Count -ne 1) {
112+
throw "Expected one baseline for $($summary.Platform)/$Scenario, found $($baselineRows.Count)."
113+
}
114+
115+
$regressions = @()
116+
foreach ($metric in @(
117+
"UniqueLeaks",
118+
"TotalLeaks",
119+
"LeakBytes",
120+
"UniquePossibleLeaks",
121+
"TotalPossibleLeaks",
122+
"PossibleLeakBytes",
123+
"UniqueReachable",
124+
"TotalReachable",
125+
"ReachableBytes"
126+
)) {
127+
$currentValue = [int64]$summary.$metric
128+
$baselineValue = [int64]$baselineRows[0].$metric
129+
if ($currentValue -gt $baselineValue) {
130+
$regressions += "$metric increased from $baselineValue to $currentValue"
131+
}
132+
}
133+
134+
if ($regressions.Count -eq 0) {
135+
$baselineStatus = "At or below baseline"
136+
}
137+
else {
138+
$baselineStatus = "$($regressions.Count) increase(s)"
139+
foreach ($regression in $regressions) {
140+
Write-Host "::warning title=Dr. Memory regression ($($summary.Platform)/$Scenario)::$regression"
141+
}
142+
}
143+
}
144+
103145
$markdown = @"
104-
| Scenario | Unique leaks | Total leaks | Leak bytes | Unique possible | Possible bytes | Unique reachable | Reachable bytes |
105-
|---|---:|---:|---:|---:|---:|---:|---:|
106-
| $Scenario | $($leaks.Unique) | $($leaks.Total) | $($leaks.Bytes) | $($possibleLeaks.Unique) | $($possibleLeaks.Bytes) | $($reachable.Unique) | $($reachable.Bytes) |
146+
| Scenario | Unique leaks | Total leaks | Leak bytes | Unique possible | Possible bytes | Unique reachable | Reachable bytes | Baseline |
147+
|---|---:|---:|---:|---:|---:|---:|---:|---|
148+
| $Scenario | $($leaks.Unique) | $($leaks.Total) | $($leaks.Bytes) | $($possibleLeaks.Unique) | $($possibleLeaks.Bytes) | $($reachable.Unique) | $($reachable.Bytes) | $baselineStatus |
107149
"@
108150
Write-Host $markdown
109151
if ($env:GITHUB_STEP_SUMMARY) {

‎.github/workflows/memory-leak-analysis.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ name: Memory leak analysis
22

33
on:
44
workflow_dispatch:
5+
schedule:
6+
- cron: 0 8 * * 1
57
push:
68
branches:
79
- main
810
paths:
911
- .github/scripts/run-drmemory.ps1
12+
- .github/memory-leak-baseline.csv
1013
- .github/workflows/memory-leak-analysis.yml
1114
- CMakeLists.txt
1215
- CMakePresets.json
@@ -25,6 +28,7 @@ on:
2528
- main
2629
paths:
2730
- .github/scripts/run-drmemory.ps1
31+
- .github/memory-leak-baseline.csv
2832
- .github/workflows/memory-leak-analysis.yml
2933

3034
permissions:
@@ -88,6 +92,7 @@ jobs:
8892
-LogDirectory drmemory-results
8993
-Scenario unit-tests
9094
-TargetPath Solutions/out/Debug/x64/UnitTests/UnitTests.exe
95+
-BaselinePath .github/memory-leak-baseline.csv
9196
-TargetArguments "--gtest_filter=-OfflineStorageTests_SQLite.StoreThousandEventsTakesLessThanASecond"
9297
9398
- name: Analyze functional tests
@@ -98,6 +103,7 @@ jobs:
98103
-LogDirectory drmemory-results
99104
-Scenario functional-tests
100105
-TargetPath Solutions/out/Debug/x64/FuncTests/FuncTests.exe
106+
-BaselinePath .github/memory-leak-baseline.csv
101107
-TargetArguments "--gtest_filter=-BasicFuncTests.killSwitchWorks"
102108
103109
- name: Analyze basic sample
@@ -107,6 +113,7 @@ jobs:
107113
-DrMemoryPath "$env:RUNNER_TEMP/DrMemory-Windows-$env:DRMEMORY_VERSION/bin64/drmemory.exe"
108114
-LogDirectory drmemory-results
109115
-Scenario sample-cpp-mini
116+
-BaselinePath .github/memory-leak-baseline.csv
110117
-TargetPath Solutions/out/Debug/x64/SampleCppMini/SampleCppMini.exe
111118
112119
- name: Verify Network List Manager is not loaded
@@ -186,6 +193,7 @@ jobs:
186193
-DrMemoryPath "$env:RUNNER_TEMP/DrMemory-Linux-$env:DRMEMORY_VERSION/bin64/drmemory"
187194
-LogDirectory drmemory-results
188195
-Scenario unit-tests
196+
-BaselinePath .github/memory-leak-baseline.csv
189197
-TargetPath out/tests/unittests/UnitTests
190198
191199
- name: Analyze functional tests
@@ -196,6 +204,7 @@ jobs:
196204
-LogDirectory drmemory-results
197205
-Scenario functional-tests
198206
-TargetPath out/tests/functests/FuncTests
207+
-BaselinePath .github/memory-leak-baseline.csv
199208
-TargetArguments "--gtest_filter=-BasicFuncTests.killSwitchWorks"
200209
201210
- name: Analyze basic sample
@@ -205,6 +214,7 @@ jobs:
205214
-DrMemoryPath "$env:RUNNER_TEMP/DrMemory-Linux-$env:DRMEMORY_VERSION/bin64/drmemory"
206215
-LogDirectory drmemory-results
207216
-Scenario sample-cpp-mini
217+
-BaselinePath .github/memory-leak-baseline.csv
208218
-TargetPath out/sample-cpp-mini/SampleCppMini
209219
210220
- name: Upload Linux reports

0 commit comments

Comments
 (0)