WebAssembly / WebAssembly/threads

memory.atomic.wait32 on the main browser thread

Open
#174 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
767
Forks
54
PR merge metrics
No merged PRs in 30d

Description

Writing some unit tests for Emscripten, I today realize that Firefox and Chrome behavior differ when one issues a memory.atomic.wait32 on the main thread.

If one issues e.g.

  (drop
   (memory.atomic.wait32 offset=12
    (local.get $0)
    (i32.const 0)
    (i64.const 135790)
   )
  )

on the main thread,

  • Firefox will raise an exception "TypeError: waiting is not allowed on this thread"
  • Chrome will immediately and silently return without performing the wait

Tried to search through the spec to find the reference for wait instruction at https://webassembly.github.io/threads/core/syntax/instructions.html#syntax-instr-atomic-memory , but was unable to figure out which is the correct behavior, or if both are?

(I am aware of Atomics.waitAsync, this question is not about that, but just about what should happen if one does attempt a memory.atomic.wait32 on the main thread)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked WebAssembly threads specification section and the provided WAST example, then reproduce memory.atomic.wait32 on the browser main thread in Firefox and Chrome. Compare both results with the specification and document which behavior is required or whether the specification needs clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.