-
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
GT_STORE_BLK - do not call memset for blocks containg gc pointers on heap #95530
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue Detailsci test
|
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, Fuzzlyn |
Azure Pipelines successfully started running 3 pipeline(s). |
Yes, that sounds right. |
I think some fallback for large structs will be needed, either as an inline loop or helper callback, otherwise we can hit encoder limitations. One of the first lessons I learned working on the JIT in #61521. |
Yeah I already hit it locally (added more tests) |
For reference, an alternative fix to introduce a new helper (with r2r format bump): EgorBo@262c43c |
It is why we have |
7393dce
to
8d9185f
Compare
53ce5fe
to
4ecfc65
Compare
PTAL @dotnet/jit-contrib @jkotas I implemented the loop (for cases when size is too big to be unrolled). Diffs are not too big and don't touch sensitive stuff it seems (except, maybe ValueTasks with large state). The loop can be additionally optimized further if needed. An alternative solution is to introduce a new helper that will TODO: finish risc-v/la64, just wanted to get a feedback first. |
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, Fuzzlyn |
Azure Pipelines successfully started running 3 pipeline(s). |
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.
You should add a section to https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/clr-abi.md detailing the GC requirements for memset/memcpy atomicity.
Another problem we discovered (with @MichalPetryka) is that RISC-V (and LA64?) don't have addressing modes for indices (base + index), only for constant imms. It means we need to prepare the address in a separate temp reg so I should add it to gcinfo or mark loop as nogc I assume. |
Yup, |
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 Thank you @EgorBo
cc @tomeksowi
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.
RISC-V part LGTM, thx @EgorBo
@BruceForstall can you please review & approve if it's fine? Jitstress and gcstress passed |
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. Minor notes on comments.
Co-authored-by: Qiao Pengcheng <qiaopengcheng@loongson.cn>
Since the last approval the only changes were in RISC/LA to address feedback from RISC/LA teams. |
@jkotas does this need to be backported to any release? Presumably the actual bug was there since .NET Framework? |
.NET Framework has a different (slower) implementation of JIT_MemSet that does not appear to have the tearing problem. It does not use
It was found via internal escalation (service crashing 3x per day). We should backport it to .NET 8. (It was hit on .NET 6, but the affected customer is planning to move to .NET 8 soon. .NET 8 backport should be good enough.) |
/backport to release/8.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/7416001475 |
This PR applies fix suggested by @jkotas to always inline "memset" for structs with GC references since
JIT_Memset
doesn't provide us with needed atomicity guarantees. An alternative solution is to introduce a new memset helper (it requires R2R format update).Was:
Now: