Skip to content

Run section AH's keyword cases in child processes, with a dump on a timeout - #108

Merged
HalRiveria merged 1 commit into
mainfrom
fix/ah-case-processes
Dec 2, 2026
Merged

HalRiveria merged 1 commit into
mainfrom
fix/ah-case-processes

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

Section AH runs each continue/break keyword case in a [PowerShell] inside the harness's own process and waits 20 s for it. On a timeout the harness called $ps.Stop(), which waits for the case to stop. A case blocked in a .NET wait never stops, so instead of a [FAIL] the whole run hung until the job's time limit. That happened once on CI, in the 'break' in -JobPollCompleted case under PowerShell 7. It passed on a rerun and hasn't been reproduced, so its cause isn't known.

What changed

  • Each keyword case now runs in a PowerShell process of its own (same version as the harness), with a 30 s limit. It doesn't go through the kit, since the kit is what's under test.
  • A case that runs past the limit:
    1. has its child processes listed;
    2. gets a full minidump written (MiniDumpWriteDump, nothing installed) to %TEMP%\pk-harness-dumps, or to PK_HARNESS_DUMP_DIR if that's set;
    3. is killed with its tree by PID (taskkill /T), even if steps 1 or 2 fail;
    4. fails with a message naming the case, its programs and the dump. The harness then goes on to the next case.
  • New assertions in AH:
    1. A case blocked in a .NET wait is cut off at its limit, with its output so far.
    2. Its ping.exe child is listed and killed with it.
    3. A program over its limit is dumped before it's killed.
  • tests.yml and module.yml set PK_HARNESS_DUMP_DIR and upload that folder as an artifact when the harness fails (7 days).
  • The README's harness paragraph mentions the limit and the dump folder.

Moving the cases out of the harness's process changes their conditions. If the CI hang depended on something in that process, it may not happen again this way.

How it was tested

  • Full harness: 737 assertions passed on Windows PowerShell 5.1 and on PowerShell 7.6.2.
  • -AsModule -Section MODULE: 292 assertions passed on both.
  • An extra case that blocks forever in ManualResetEvent.WaitOne(), added locally and not committed:
    • On main, the harness hung after that case's continue line, with no [FAIL], until it was killed at 150 s. That's the same thing CI showed.
    • On this branch it failed after 30 s with the case named, wrote a 333 MB dump, and the run went on to finish.
  • dotnet-dump analyze on that dump showed the stuck thread in WaitHandle.WaitOne(). The FunctionContext objects on its stack named the PowerShell call chain, innermost first: the callback, then Invoke-PkProcessDispatchCore, Invoke-PkProcessDispatch and Invoke-KwDispatch.
  • Section AH takes about 33 s longer per run, from starting 28 PowerShell processes.

🤖 Generated with Claude Code

…imeout

Each 'continue'/'break' case ran in a [PowerShell] inside the harness's own
process, with a 20 s wait. On a timeout the harness called Stop(), which waits
for the case to stop; a case blocked in a .NET wait never does, so a hung case
hung the whole run with no [FAIL]. Each case now runs in a PowerShell process
of its own with a 30 s limit. One that runs past it is killed by PID with its
tree, fails naming the case and the programs it had running, and leaves a full
minidump of its process (MiniDumpWriteDump) in %TEMP%\pk-harness-dumps or
PK_HARNESS_DUMP_DIR. CI uploads that folder when the harness fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit 59bcc79 into main Dec 2, 2026
6 checks passed
@HalRiveria
HalRiveria deleted the fix/ah-case-processes branch December 2, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants