-
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
JIT: fix double reporting of some GC frame slots #71245
Conversation
If there is a gc struct local that is dependently promoted, the struct local may be untracked while the promoted gc fields of the struct are tracked. If so, the jit will double report the stack offset for the gc field, first as an untracked slot, and then as a tracked slot. Detect this case and report the slot as tracked only. Closes dotnet#71005.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsIf there is a gc struct local that is dependently promoted, the struct If so, the jit will double report the stack offset for the gc field, Detect this case and report the slot as tracked only. Closes #71005.
|
@dotnet/jit-contrib PTAL Not sure yet why this hasn't bitten us before, or (perhaps) only seems to have caused arm64 OSR failures. This bit of GC reporting has not changed in many many years. |
This seems to be the wrong approach. During So evidently something goes wrong here (perhaps just with OSR) and we get this range wrong, or are not properly ordering the frame so that we're intermingling locals improperly or something. Continuing to investigate. |
@AndyAyersMS FWIW, I investigated this earlier today, perhaps my conclusions could be of help. Details (note these are purely from looking at the code and may be partially or completely incorrect.)Ordinarily the frame allocation is done s.t. the "tracked GC refs on stack" are all contained in one region:
The way reporting of "tracked GC refs on stack" is done, codegen calculates the low/high offsets within which they reside: runtime/src/coreclr/jit/codegencommon.cpp Lines 5634 to 5654 in 6bc83f1
So, ordinarily, we would not have any dependently promoted fields in this range (since they'd be in the "untracked" group). Presumably, OSR violates this by virtue of having "fixed" offsets for some locals. When the emitter looks at which of these slots actually need to be reported here: runtime/src/coreclr/jit/emit.cpp Lines 6543 to 6555 in 6bc83f1
It calls |
@SingleAccretion thanks, I have been looking at exactly this area. Seems like there are two options: |
Judging by the code which binds the offset range for "tracked on-stack GC refs", it seems to me that "dependently promoted fields" cannot really be tracked, otherwise we would need to include them into the range. |
For OSR the tracked range may end up including some trackable dependent promoted locals. They won't ever inspire or extend the range, but they may fall within the range set by other on frame gc vars. I updated the code to detect this case and report as tracked, by querying the emitter to see if the offset falls within the tracked range. I suppose there's still a concern that we might not properly track these lifetimes (since say they can have aliased reads/writes via the parent) in which case we'd need to find a way to exclude them from tracked reporting somehow. |
Was hoping to scope this down to just an OSR change, but am seeing some non-OSR hits for this new check:
In this case Or maybe I need to exclude the upper end of the offset range. That's probably it. |
Looks like may be arm with profiler callbacks ends up tripping this; likely need to exempt "prespilled" cases too. |
/azp run runtime-coreclr libraries-pgo |
Azure Pipelines successfully started running 1 pipeline(s). |
PTAL @dotnet/jit-contrib Libraries-pgo has some known failures so I didn't expect it to run cleanly. |
Yes... I think some unrolled varieties of block copies, especially those using SIMD registers, do not properly report GC-ness for the destination stack slots. Likewise for our special calls with tracked "return buffers". |
Ok, I've switched things around to always report the fields of dependently promoted GC structs as untracked. |
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 modulo nits.
/azp run runtime-coreclr libraries-pgo |
Azure Pipelines successfully started running 1 pipeline(s). |
Was hoping this plus other recent PRs would have cleaned up libraries-pgo, but there is still more going on there. Going to see if the new slew of arm64 failures repro locally (looks like a machine issue but I can't tell for sure). |
Kicked off a new libraries-pgo baseline to see what that looks like. |
libraries-pgo picture is still a bit confusing but I think this change is good. |
If there is a gc struct local that is dependently promoted, the struct
local may be untracked while the promoted gc fields of the struct are
tracked.
If so, the jit will double report the stack offset for the gc field,
first as an untracked slot, and then as a tracked slot.
Detect this case and report the slot as tracked only.
Closes #71005.