Skip to content

[wasm] Volatile intrinsics not implemented #124477

Closed

Description

@jjonescz

Description

Some intrinsics like

public static void ReadBarrier() => ReadBarrier();

don't seem to be implemented on WebAssembly, leading to failures when referenced libraries call them.

Reproduction Steps

Create a minimal blazor wasm app, call Volatile.ReadBarrier() in it, run it.

Expected behavior

Runs. I think the runtime could simply use Interlocked.MemoryBarrier for correct (albeit perhaps suboptimal) behavior for Volatile.ReadBarrier and Volatile.WriteBarrier.

Actual behavior

Crashes with stack overflow (since the default implementation seems to be that the method is just calling itself).

Regression?

Probably not, these seem to be new APIs in .NET 10.

Known Workarounds

Don't use Volatile.ReadBarrier/WriteBarrier but that's difficult if it's used by referenced libraries whose source code I don't control.

Configuration

No response

Other information

No response

Activity

  1. added
    untriaged
    on Feb 16, 2026
  2. added
    needs-area-label
    on Feb 16, 2026
  3. added
    arch-wasm
    on Feb 16, 2026
  4. dotnet-policy-service commented on Feb 16, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  5. jkotas commented on Feb 16, 2026

    @jkotas
    Member

    #107843 that introduced these APIs did not come with any tests.

    @hamarb123 @VSadov

  6. added and removed
    needs-area-label
    on Feb 16, 2026
  7. dotnet-policy-service commented on Feb 16, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @VSadov
    See info in area-owners.md if you want to be subscribed.

  8. hamarb123 commented on Feb 16, 2026

    @hamarb123
    Contributor

    that introduced these APIs did not come with any tests

    Context: #107843 (comment)

    Maybe just adding a test that checks the call succeeds for now would suffice? I can add one if wanted, or someone else could (probably wouldn't take long / be hard - the potentially more difficult part would be implementing it on places without it).

  9. VSadov commented on Feb 16, 2026

    @VSadov
    Member

    If wasm is single-threaded, then ReadBarrier() could have a noop implementation.

  10. jkotas commented on Feb 18, 2026

    @jkotas
    Member

    Fixed by #124538. We still need to add some tests.

  11. removed
    untriaged
    on Feb 23, 2026
  12. added this to the Future milestone on Feb 23, 2026
  13. locked and limited conversation to collaborators on Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-System.Threading

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions