Skip to content

[ResourceLock] Replace broad DoNotParallelize with narrow ResourceLock in CrashDumpTests - #11192

Merged
Amaury Levé (Evangelink) merged 2 commits into
microsoft:mainfrom
nohwnd-bot:resource-lock/crashdump-unittests-ea26befd8b458254
Sep 11, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
microsoft:mainfrom
nohwnd-bot:resource-lock/crashdump-unittests-ea26befd8b458254

Conversation

@nohwnd-bot

@nohwnd-bot nohwnd-bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the original ResourceLock refactoring so the process-wide AppDomain slot is protected for both its writer and every indirect reader, and hardens the generating workflow against repeating this mistake.

Test synchronization fix

Microsoft.Testing.Extensions.UnitTests runs with method-level parallelization. CrashDumpTests.OnTestHostProcessExitedAsync_ProcessKilledByHangDump_DeletesSequenceFileAndDoesNotPublishArtifacts temporarily writes the process-wide "ProcessKilledByHangDump" AppDomain slot, while several other tests indirectly read it through CrashDumpProcessLifetimeHandler.OnTestHostProcessExitedAsync.

The class now declares:

[ResourceLock(ProcessKilledByHangDumpAppDomainDataResource, Mode = ResourceAccessMode.Read)]

and the mutating test retains the same key with the default ReadWrite mode. This lets read-only tests remain concurrent with each other while excluding them whenever the slot is being changed.

Workflow hardening

The ResourceLock refactoring workflow now requires a resource coverage matrix before removing [DoNotParallelize]:

  • direct test writers;
  • production readers and writers;
  • every test invoking those production paths; and
  • the matching lock declaration and access mode for each test.

It explicitly rejects literal-key grep as sufficient evidence, requires a declaration-reconciliation self-review against the parallel-safety audit rubric, and fails closed by retaining [DoNotParallelize] or producing no PR when any observer is unknown or uncovered.

Validation

  • .\build.cmd -projects "$PWD\test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj" -test -bl — succeeded with 0 warnings and 0 errors; tests passed on net462, net472, net8.0, and net9.0.
  • gh aw compile resource-lock-refactoring --strict --no-check-update — succeeded.
  • python .github/scripts/check_action_pins.py — passed; 2,546 references checked.

…ests

Microsoft.Testing.Extensions.UnitTests is parallelized with
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)].
OnTestHostProcessExitedAsync_ProcessKilledByHangDump_DeletesSequenceFileAndDoesNotPublishArtifacts
carried a class-wide-effective [DoNotParallelize] even though it touches
exactly one process-wide resource: the AppDomain.CurrentDomain data slot
"ProcessKilledByHangDump" read by CrashDumpProcessLifetimeHandler and
written by HangDumpProcessLifetimeHandler. No other test in the project
reads or writes that slot, so a method-level [ResourceLock] on this one
test is sufficient and lets it run concurrently with the rest of the
class again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 11, 2026 06:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unlocked tests indirectly read the shared AppDomain slot and can race with the modified test.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors CrashDump unit-test synchronization from broad non-parallel execution to a named resource lock.

Changes:

  • Adds a constant identifying the AppDomain data slot resource.
  • Replaces [DoNotParallelize] with a method-level [ResourceLock].
File summaries
File Description
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs Narrows synchronization for the process-killed-by-hang-dump test.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review September 11, 2026 08:05
Cover indirect CrashDump handler readers with a shared read lock and upgrade the AppDomain-slot mutator to exclusive access. Require the refactoring workflow to trace production read sets and prove declaration coverage before removing DoNotParallelize.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The synchronization covers the relevant readers and writer, and the workflow artifact is consistently regenerated.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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.

3 participants