Skip to content

[release/10.0] [mono][interp] Add missing intrinsic for Volatile.ReadBarrier/WriteBarrier - #130303

Merged
svick merged 2 commits into
release/10.0from
backport/pr-124538-to-release/10.0
Aug 6, 2026
Merged

svick merged 2 commits into
release/10.0from
backport/pr-124538-to-release/10.0

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #124538 to release/10.0

/cc @BrzVlad

Customer Impact

  • Customer reported
  • Found internally

Applications calling Volatile.ReadBarrier/WriteBarrier will crash when running under mono interpreter. This can impact ios, android debug and wasm. A customer upgrading to Microsoft.CodeAnalysis.CSharp 5.6.0 encountered this error.

Regression

  • Yes
  • No

This new api was added in .NET10. As more libraries will use this new API, this problem will become more frequent.

Testing

Tested on simple app calling this API.

Risk

Low. This just adds an intrisic for this API which conservatively emits a full memory barrier.

…rrier

For simplicity, this just adds full memory barriers. Previously, calling this code would lead to stack overflow due to recursively calling itself.
@BrzVlad BrzVlad added the Servicing-consider Issue for next servicing release review label Jul 7, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @vitek-karas, @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@rbhanda rbhanda modified the milestones: 10.0.x, 10.0.11 Jul 7, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "765b8f1dd0d0e6e74d4fdf6adaaf497e46a18f36",
  "last_dispatched_base_ref": "release/10.0",
  "last_dispatched_base_sha": "aced99138b1efad4a5361ff68ea1951c860dcbda",
  "last_reviewed_commit": "765b8f1dd0d0e6e74d4fdf6adaaf497e46a18f36",
  "last_reviewed_base_ref": "release/10.0",
  "last_reviewed_base_sha": "aced99138b1efad4a5361ff68ea1951c860dcbda",
  "last_recorded_worker_run_id": "29681939970",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "765b8f1dd0d0e6e74d4fdf6adaaf497e46a18f36",
      "review_id": 4730543769
    }
  ]
}

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holistic Review

Motivation: This is a backport of #124538 to release/10.0. The Volatile.ReadBarrier/Volatile.WriteBarrier APIs are new in .NET 10. Under the Mono interpreter these methods had no intrinsic handling, so calls crash. This impacts iOS, Android debug, and WASM scenarios, and a customer hit it after upgrading Microsoft.CodeAnalysis.CSharp.

Approach: Adds an intrinsic case in interp_handle_intrinsics that maps parameterless System.Threading.Volatile.ReadBarrier/WriteBarrier to MINT_MONO_MEMORY_BARRIER, mirroring the existing Thread.MemoryBarrier handling. A new VolatileTests set exercises the barriers directly, via reflection, and interleaved with Volatile.Read/Write, and is wired into the test csproj.

Summary: The change is minimal, self-contained, and faithfully matches the original PR. Emitting a full memory barrier is conservatively correct for both the acquire-style read barrier and the release-style write barrier, and the param_count == 0 guard keeps the intrinsic scoped to the intended overloads. The test asserts only that the calls do not throw (the equality assertions on single-threaded, non-shared locals are trivially true), which aligns with the crash-fix intent. No correctness, security, or performance concerns. Verdict: LGTM.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 40.7 AIC · ⌖ 10.2 AIC · ⊞ 10K

@snakefoot

Copy link
Copy Markdown
Contributor

@rbhanda + @JulieLeeMSFT Have the merge been forgotten? Maybe update the milestone?

@svick

svick commented Aug 6, 2026

Copy link
Copy Markdown
Member

Hi,

the code complete date for 10.0.12 (the September 2026 release) is Monday 10 August. Make sure to merge this PR on that date at the latest, or it won't make it into that release.

As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval).

@svick

svick commented Aug 6, 2026

Copy link
Copy Markdown
Member

/ba-g timeouts on wasm

@svick
svick merged commit 319ee47 into release/10.0 Aug 6, 2026
118 of 122 checks passed
@svick
svick deleted the backport/pr-124538-to-release/10.0 branch August 6, 2026 14:20
@snakefoot

Copy link
Copy Markdown
Contributor

@rbhanda + @JulieLeeMSFT Maybe update the milestone?

nickrandolph added a commit to unoplatform/Uno.DotnetRuntime.WebAssembly that referenced this pull request Aug 7, 2026
- The pin (`081d220c`, 2026-02-18) is 140 commits behind `release/10.0`
  and `behind_by: 0` — a straight fast-forward on the servicing branch.
- Picks up dotnet/runtime#130303, the missing Mono interpreter intrinsic
  for `Volatile.ReadBarrier`/`WriteBarrier`. Both are `[Intrinsic]` with a
  self-calling managed fallback, so an interpreted `net10.0` call path
  recursed to StackOverflowException and took the runtime down.
- All 11 existing patches were verified to `git apply` cleanly against
  the new base, in order. No rebase required.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants