Skip to content

Commit b4becd9

Browse files
committed
measure-693 round 2: the fixtures directory no longer shares a name with the loop variable; the shim runs inside its workspace; cdb records the crash
1 parent c19741a commit b4becd9

1 file changed

Lines changed: 38 additions & 9 deletions

File tree

‎.github/measure-693/measure.ps1‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $ProgressPreference = 'SilentlyContinue'
2222
$Ver = '2026.9.25.1'
2323
$XlVer = '2026.9.20.1'
2424
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path
25-
$Fx = Join-Path $Here 'fixtures'
25+
$FixturesDir = Join-Path $Here 'fixtures' # NOT $Fx: PowerShell names are case-insensitive
2626

2727
function Reading([string]$id, [string]$text) {
2828
$line = "READING ${id}: $text"
@@ -40,14 +40,15 @@ function Hex32([int]$code) {
4040
# Run a program with an explicit working directory (CreateProcessW underneath,
4141
# so the directory reaches the child intact). Returns exit code and output
4242
# decoded as UTF-8 plus the raw bytes.
43-
function Run([string]$exe, [string[]]$argv, [string]$cwd, [int]$timeoutSec = 600, [hashtable]$envx = @{}) {
43+
function Run([string]$exe, [string[]]$argv, [string]$cwd, [int]$timeoutSec = 600, [hashtable]$envx = @{}, [string]$stdin = $null) {
4444
$psi = [System.Diagnostics.ProcessStartInfo]::new()
4545
$psi.FileName = $exe
4646
foreach ($a in $argv) { [void]$psi.ArgumentList.Add($a) }
4747
$psi.WorkingDirectory = $cwd
4848
$psi.UseShellExecute = $false
4949
$psi.RedirectStandardOutput = $true
5050
$psi.RedirectStandardError = $true
51+
if ($stdin) { $psi.RedirectStandardInput = $true } # [string] turns $null into ''
5152
foreach ($k in $envx.Keys) { $psi.Environment[$k] = $envx[$k] }
5253
$r = [ordered]@{ code = $null; out = ''; err = ''; outBytes = [byte[]]@(); timedOut = $false; startError = '' }
5354
try {
@@ -56,6 +57,7 @@ function Run([string]$exe, [string[]]$argv, [string]$cwd, [int]$timeoutSec = 600
5657
$r.startError = $_.Exception.Message
5758
return $r
5859
}
60+
if ($stdin) { $p.StandardInput.Write($stdin); $p.StandardInput.Close() }
5961
$o = [System.IO.MemoryStream]::new(); $e = [System.IO.MemoryStream]::new()
6062
$t1 = $p.StandardOutput.BaseStream.CopyToAsync($o)
6163
$t2 = $p.StandardError.BaseStream.CopyToAsync($e)
@@ -159,12 +161,17 @@ $Bat = Join-Path $Root 'mcpp.bat'
159161
$VendXl = Join-Path $Root 'registry\bin\xlings.exe'
160162
Reading 'zip.layout' ((Get-ChildItem -LiteralPath $Root -Recurse -File | ForEach-Object { $_.FullName.Substring($Root.Length + 1) }) -join ', ')
161163

162-
# WER local dumps, so a fast-fail leaves its code and module behind.
164+
# WER local dumps, so a fast-fail leaves its code and module behind. WER is
165+
# switched on first: the first round found it produced neither events nor dumps.
166+
try { Enable-WindowsErrorReporting -ErrorAction Stop | Out-Null } catch { Write-Host "Enable-WindowsErrorReporting: $($_.Exception.Message)" }
167+
try { Set-Service WerSvc -StartupType Manual -ErrorAction Stop; Start-Service WerSvc -ErrorAction Stop } catch { Write-Host "WerSvc: $($_.Exception.Message)" }
168+
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting' -Name Disabled -Value 0 -PropertyType DWord -Force | Out-Null
169+
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting' -Name DontShowUI -Value 1 -PropertyType DWord -Force | Out-Null
163170
foreach ($img in 'mcpp.exe', 'xlings.exe', 'cmd.exe') {
164171
$k = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\$img"
165172
New-Item -Path $k -Force | Out-Null
166173
New-ItemProperty -Path $k -Name DumpFolder -Value 'C:\dumps' -PropertyType ExpandString -Force | Out-Null
167-
New-ItemProperty -Path $k -Name DumpType -Value 1 -PropertyType DWord -Force | Out-Null
174+
New-ItemProperty -Path $k -Name DumpType -Value 2 -PropertyType DWord -Force | Out-Null
168175
}
169176

170177
# The UTF-8 activeCodePage copy, embedded with the SDK's mt.exe.
@@ -223,10 +230,18 @@ foreach ($dk in $Dirs.Keys) {
223230
$d = $Dirs[$dk]
224231
foreach ($ek in $Entry.Keys) {
225232
$r = Run $Entry[$ek] @('--version') $d 120
233+
if ($r.startError) { Reading "q1.$dk.$ek" "PROBE DEFECT: did not start: $($r.startError)"; continue }
226234
Reading "q1.$dk.$ek" "exit=$(Hex32 $r.code) out=$(OneLine ($r.out + $r.err))"
227235
}
228236
$b = Run "$env:SystemRoot\System32\cmd.exe" @('/d', '/c', $Bat, '--version') $d 120
229237
Reading "q1.$dk.release-bat" "exit=$(Hex32 $b.code) out=$(OneLine ($b.out + $b.err))"
238+
if ($Shim) {
239+
# Inside the workspace whose .xlings.json pins mcpp, so the shim resolves it.
240+
$wd = Join-Path 'C:\pin' (Split-Path -Leaf $d)
241+
New-Item -ItemType Directory -Force -Path $wd | Out-Null
242+
$s2 = Run $Shim @('--version') $wd 120
243+
Reading "q1.$dk.xlings-shim-in-workspace" "exit=$(Hex32 $s2.code) out=$(OneLine ($s2.out + $s2.err))"
244+
}
230245
}
231246
Start-Sleep -Seconds 5
232247
$ev = Get-WinEvent -FilterHashtable @{ LogName = 'Application'; Id = 1000 } -ErrorAction SilentlyContinue |
@@ -243,6 +258,18 @@ foreach ($x in $ev2) {
243258
$dumps = Get-ChildItem C:\dumps -File -ErrorAction SilentlyContinue
244259
Reading 'q1.dumps' (($dumps | ForEach-Object { "$($_.Name) ($($_.Length) B)" }) -join ', ')
245260
$cdb = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\x64\cdb.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
261+
Reading 'q1.cdb-present' "$(if ($cdb) { $cdb.FullName } else { 'no cdb.exe under Windows Kits\10\Debuggers\x64' })"
262+
if ($cdb -and $XlExe) {
263+
# Break on every C++ throw (print the record, the what() of an MSVC-STL
264+
# std::exception at +8, and the stack) and on the fast fail.
265+
$cmds = 'sxe -c ".echo EH-THROWN;.exr -1;da poi(@$exr_param1+8);kc 25;gc" eh; sxe -c ".echo FASTFAIL;.exr -1;kc 40;q" c0000409; g'
266+
$symp = 'srv*C:\sym*https://msdl.microsoft.com/download/symbols'
267+
$live = Run $cdb.FullName @('-G', '-lines', '-y', $symp, '-c', $cmds, $XlExe, '--version') $Dirs['nonacp'] 300
268+
Write-Host '----- cdb: xlings --version in the non-ACP directory -----'
269+
Write-Host $live.out
270+
$keep = ($live.out -replace "`r", '' -split "`n" | Where-Object { $_ -match 'EH-THROWN|FASTFAIL|ExceptionCode|ExceptionAddress|NumberParameters|Parameter\[|xlings|ucrtbase|KERNELBASE|vcruntime|msvcp' } | Select-Object -First 45) -join ' || '
271+
Reading 'q1.cdb-live' $keep
272+
}
246273
if ($cdb -and $dumps) {
247274
$dmp = $dumps | Select-Object -First 1
248275
$a = Run $cdb.FullName @('-z', $dmp.FullName, '-c', '.exr -1; kc 30; q') 'C:\dumps' 600
@@ -264,22 +291,24 @@ if ($Patched) { $Builders['patched'] = $Patched }
264291
$first = $true
265292
foreach ($dk in $Dirs.Keys) {
266293
foreach ($bk in $Builders.Keys) {
267-
foreach ($fx in 'hello', 'bmn', 'bmw') {
268-
$proj = Join-Path $Dirs[$dk] "$bk-$fx"
269-
Copy-Item -LiteralPath (Join-Path $Fx $fx) -Destination $proj -Recurse -Force
294+
foreach ($fixture in 'hello', 'bmn', 'bmw') {
295+
$proj = Join-Path $Dirs[$dk] "$bk-$fixture"
296+
Copy-Item -LiteralPath (Join-Path $FixturesDir $fixture) -Destination $proj -Recurse -Force
297+
if (-not (Test-Path -LiteralPath (Join-Path $proj 'mcpp.toml'))) { Reading "probe.copy.$dk.$bk.$fixture" 'PROBE DEFECT: the fixture was not copied'; continue }
270298
$t = if ($first) { 2400 } else { 900 }
271299
$first = $false
272300
$sw = [System.Diagnostics.Stopwatch]::StartNew()
273301
$r = Run $Builders[$bk] @('build') $proj $t
274302
$secs = [int]$sw.Elapsed.TotalSeconds
275-
$id = "q2.$dk.$bk.$fx"
303+
$id = "q2.$dk.$bk.$fixture"
276304
$exeOut = ''
277305
$exe = Get-ChildItem -LiteralPath (Join-Path $proj 'target') -Recurse -Filter probe.exe -ErrorAction SilentlyContinue |
278306
Where-Object { $_.FullName -match '\\bin\\' } | Select-Object -First 1
279307
if ($exe) {
280308
$x = Run $exe.FullName @() $proj 60
281309
$exeOut = " run: exit=$(Hex32 $x.code) $(OneLine ($x.out + $x.err))"
282310
}
311+
if ($r.startError) { Reading $id "PROBE DEFECT: did not start: $($r.startError)"; continue }
283312
Reading $id "exit=$(Hex32 $r.code) time=${secs}s timedOut=$($r.timedOut)$exeOut"
284313
if ($r.code -ne 0 -or $r.timedOut) {
285314
Reading "$id.tail" (Tail ($r.out + $r.err) 14)
@@ -293,7 +322,7 @@ foreach ($dk in $Dirs.Keys) {
293322
if ($ninja) { Reading "$id.build-ninja" (EncodingReport $ninja.FullName 'repro-' $NeedleNonAcp) }
294323
Reading "$id.cdb" (EncodingReport $cdbj 'repro-' $NeedleNonAcp)
295324
}
296-
if ($fx -ne 'hello') {
325+
if ($fixture -ne 'hello') {
297326
$gen = Get-ChildItem -LiteralPath (Join-Path $proj 'target') -Recurse -Filter gen.cpp -ErrorAction SilentlyContinue | Select-Object -First 1
298327
Reading "$id.generated" ("gen.cpp " + $(if ($gen) { 'written under target' } else { 'absent under target' }))
299328
}

0 commit comments

Comments
 (0)