-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/9.0-preview7] JIT: Fix placement of GT_START_NOGC
for tailcalls in face of bulk copy with write barrier calls
#105572
Merged
hoyosjs
merged 2 commits into
release/9.0-preview7
from
backport/pr-105551-to-release/9.0-preview7
Jul 26, 2024
Merged
[release/9.0-preview7] JIT: Fix placement of GT_START_NOGC
for tailcalls in face of bulk copy with write barrier calls
#105572
hoyosjs
merged 2 commits into
release/9.0-preview7
from
backport/pr-105551-to-release/9.0-preview7
Jul 26, 2024
Conversation
This file contains 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
…opy with write barrier calls When the JIT generates code for a tailcall it must generate code to write the arguments into the incoming parameter area. Since the GC ness of the arguments of the tailcall may not match the GC ness of the parameters, we have to disable GC before we start writing these. This is done by finding the earliest `GT_PUTARG_STK` node and placing the start of the NOGC region right before it. In addition, there is logic to take care of potential overlap between the arguments and parameters. For example, if the call has an operand that uses one of the parameters, then we must take care that we do not override that parameter with the tailcall argument before the use of it. To do so, we sometimes may need to introduce copies from the parameter locals to locals on the stack frame. This used to work fine, however, with #101761 we started transforming block copies into managed calls in certain scenarios. It was possible for the JIT to decide to introduce a copy to a local and for this transformation to then kick in. This would cause us to end up with the managed helper call after starting the nogc region. In checked builds this would hit an assert during GC scan; in release builds, it would end up with corrupted data. The fix here is to make sure we insert the `GT_START_NOGC` after all the potential temporary copies we may introduce as part of the tailcat stll logic. There was an additional assumption that the first `PUTARG_STK` operand was the earliest one in execution order. That is not guaranteed, so this change stops relying on that as well by introducing a new `LIR::FirstNode` and using that to determine the earliest `PUTARG_STK` node. Fix #102370 Fix #104123 Fix #105441
dotnet-issue-labeler
bot
added
the
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
label
Jul 26, 2024
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
EgorBo
approved these changes
Jul 26, 2024
CC @jeffschwMSFT for approval. |
cc @carlossanlop. |
Have we received Tactics approval? |
hoyosjs
added
Servicing-approved
Approved for servicing release
and removed
Servicing-consider
Issue for next servicing release review
labels
Jul 26, 2024
jeffschwMSFT
approved these changes
Jul 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This was referenced Jul 30, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Servicing-approved
Approved for servicing release
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.
Backport of #105551 to release/9.0-preview7
/cc @hoyosjs @jakobbotsch
Customer Impact
Customer code is subject to crashes, memory corruption, and process control reaching unexplainable points.
For instance, Roslyn has been observed crashing in several unexplainable ways. Some of the observed cases were tracked down to a GC hole caused by a safe point contained in a no-gc region of parameter setup in fast tail calls. The GC would kick when the method was calling
BulkMoveWithWriteBarrier
to copy a large struct into the frame and this would result in a bad object pointer getting copied. This fix removed the safe point from the region.#102370
#104123
#105441
dotnet/roslyn-analyzers#7349
dotnet/dnceng#3305
Testing
Regression test added and manual verification of partner scenarios.