Skip to content

Fix thread-unsafe HashSet in Parallel.ForEach cleanup and dry-run guard ordering - #493

Closed
saurabhhhcodes wants to merge 1 commit into
DotDev262:mainfrom
saurabhhhcodes:fix/winhome-batch-1
Closed

Fix thread-unsafe HashSet in Parallel.ForEach cleanup and dry-run guard ordering#493
saurabhhhcodes wants to merge 1 commit into
DotDev262:mainfrom
saurabhhhcodes:fix/winhome-batch-1

Conversation

@saurabhhhcodes

Copy link
Copy Markdown
Contributor

Bug 1: Thread-unsafe HashSet<string> in Parallel.ForEach

confirmedApplied is a non-thread-safe HashSet being modified via .Remove() inside a Parallel.ForEach at src/Engine.cs:163,175. This causes race conditions including incorrect state tracking. Wrapped remove operations with a lock.

Bug 2: Dry-run guard ordering in registry cleanup

_registry.Revert(...) was called before the !dryRun check at src/Engine.cs:160. While Revert currently respects dryRun internally, the ordering violates defense-in-depth — a mutating operation should never precede its dry-run guard. Reordered to check !dryRun first and pass false explicitly.

@DotDev262

Copy link
Copy Markdown
Owner

Closing this PR per repository guidelines: PRs from non-assignees are not accepted (issues must be assigned before submitting pull requests). Furthermore, confirmedApplied in src/Engine.cs is already a thread-safe ConcurrentDictionary<string, byte> on main using .TryRemove().

@DotDev262 DotDev262 closed this Jul 30, 2026
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