Repository navigation
Reacquire on Yield thread in TarDirectory and Untar - #15338
Merged
Merged
Conversation
Both tasks called BuildEngine3.Yield() inside an async method and Reacquire() after an await with ConfigureAwait(false), so Reacquire could run on a thread-pool thread. TaskHost requires Reacquire on the thread that called Yield; the failed call left the request in the Yielding state and the scheduler failed with MSB0001. Move Yield/Reacquire into the synchronous Execute() around the blocking wait. MockEngine now enforces the same rule, and regression tests run each task on a dedicated thread with a 1 MB file so the I/O completes asynchronously. Fixes dotnet#15331 Co-authored-by: Cursor <[email protected]>
am11
force-pushed
the
bugfix/tar-yield-reacquire-thread
branch
from
October 20, 2026 22:09
a6d47f5 to
436b6db
Compare
rainersigwald
approved these changes
Oct 21, 2026
rainersigwald
left a comment
Member
There was a problem hiding this comment.
Nice, thanks. I support backporting to 11 servicing.
JanProvaznik
approved these changes
Oct 22, 2026
Member
Author
|
/backport to vs18.12 |
Contributor
|
Started backporting to |
Contributor
|
@am11 an error occurred while backporting to |
Member
Author
|
@JanProvaznik, could you please trigger the backport? I don't have permission in this repo. |
Member
|
/backport to vs18.12 |
Contributor
|
Started backporting to |
Contributor
|
@rainersigwald backporting to git am output$ git cherry-pick e5ccd1e79e9e4799844a336c6eadc9ccd2b785f2
Auto-merging src/Tasks/TarDirectory.cs
CONFLICT (content): Merge conflict in src/Tasks/TarDirectory.cs
Auto-merging src/Tasks/Untar.cs
CONFLICT (content): Merge conflict in src/Tasks/Untar.cs
error: could not apply e5ccd1e79... Reacquire on Yield thread in TarDirectory and Untar (#15338)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Reacquire on Yield thread in TarDirectory and Untar
Using index info to reconstruct a base tree...
M src/Tasks/TarDirectory.cs
M src/Tasks/Untar.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Tasks/TarDirectory.cs
CONFLICT (content): Merge conflict in src/Tasks/TarDirectory.cs
Auto-merging src/Tasks/Untar.cs
CONFLICT (content): Merge conflict in src/Tasks/Untar.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Reacquire on Yield thread in TarDirectory and Untar
Error: The process '/usr/bin/git' failed with exit code 128 |
This was referenced Oct 23, 2026
JanProvaznik
added a commit
that referenced
this pull request
Nov 9, 2026
Backport of #15338 to vs18.12. Fixes #15331 Work item (Internal use): ### Summary `TarDirectory` and `Untar` called `BuildEngine3.Yield()` inside an async method and `Reacquire()` after an `await` with `ConfigureAwait(false)`, so `Reacquire` could run on a thread-pool thread. TaskHost requires `Reacquire` on the thread that called `Yield`; the failed call left the request in the Yielding state and the scheduler failed with MSB0001. This moves `Yield`/`Reacquire` into the synchronous `Execute()` around the blocking wait. ### Customer Impact Builds using the `TarDirectory` or `Untar` tasks can fail intermittently with MSB0001 (internal error) when the async I/O completes on a different thread than the one that yielded. ### Regression? N/A. `TarDirectory` and `Untar` are new in .NET 11, so there is no earlier shipped behavior to regress from. ### Testing Regression tests added in #15338 run each task on a dedicated thread with a 1 MB file so the I/O completes asynchronously ### Risk Low. The change is limited to the two tasks' Yield/Reacquire placement. --------- Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JanProvaznik <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both tasks called BuildEngine3.Yield() inside an async method and Reacquire() after an await with ConfigureAwait(false), so Reacquire could run on a thread-pool thread. TaskHost requires Reacquire on the thread that called Yield; the failed call left the request in the Yielding state and the scheduler failed with MSB0001.
Move Yield/Reacquire into the synchronous Execute() around the blocking wait. MockEngine now enforces the same rule, and regression tests run each task on a dedicated thread with a 1 MB file so the I/O completes asynchronously.
Fixes #15331