You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) Ordinary field load is hoisted out of a loop across a Volatile.Read #133579
The loop exits only after two iterations saw Ready != 0, so the returned box.Value load runs
after an acquire in an earlier iteration. DOTNET_JitDoLoopHoisting=0 and DOTNET_JITMinOpts=1
both print this, 5 of 5 runs each.
Actual
reader saw 0
Reproduced on 5 of 5 runs. The plain box.Value load is hoisted out of the loop even though it is
followed by a Volatile.Read acquire in the same loop body, so it is executed once before the
writer publishes and never re-read.
Platform
Windows x64, .NET 11 (dotnet/runtime main @ a0b86b1, Checked build). Requires DOTNET_TieredCompilation=0; no special CPU features.
@AndyAyersMS would this be considered for backport to at least 10 and 11? I think I probably have some code that could run into this. And to me, this seems like a bug that is unlikely to be correctly root-caused by an AI, since it relies on it:
Causing a crash (or somehow otherwise noticing it) rather than just some silent corruption
AI not finding some other unrelated plausible cause, as the issue is likely hard to reproduce (unless you already know what or where the bug is)
AI being certain of its root cause being a bug in in the runtime's implementation of volatile, rather than it thinking "maybe i just got the memory model wrong and volatile is more like volatile in c++, etc."
Likely in the real world, the issue is spread across multiple methods & relies on inlining, making it harder again
Activity
dotnet-policy-service commentedon Sep 10, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Sep 10, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
JIT: Prevent loop hoisting across volatile reads (#133825)
JIT: Prevent loop hoisting across volatile reads (dotnet#133825)
EgorBo commentedon Sep 18, 2026
Affected SDK versions:
hamarb123 commentedon Sep 18, 2026
@AndyAyersMS would this be considered for backport to at least 10 and 11? I think I probably have some code that could run into this. And to me, this seems like a bug that is unlikely to be correctly root-caused by an AI, since it relies on it:
volatile, rather than it thinking "maybe i just got the memory model wrong and volatile is more like volatile in c++, etc."[release/11.0] JIT: Prevent loop hoisting across volatile reads (#134351
snakefoot commentedon Oct 8, 2026
@JulieLeeMSFT + @AndyAyersMS Possible to get backport to NET10 since also affected?