Mutex::try_lock doesn't error in wasm32-emscripten
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Mutex::try_lock doesn't produce an Err in wasm32-emscripten.
use std::sync::Mutex;
fn main() {
let m: Mutex<u32> = Mutex::new(1);
let a = m.try_lock().unwrap();
let b = m.try_lock().unwrap();
println!("a + b = {}", *a + *b)
}
In x64, compiling and running this produces:
thread 'main' panicked at try_lock.rs:6:26:
called `Result::unwrap()` on an `Err` value: "WouldBlock"
When built with --target=wasm32-unknown-emscripten (default non-pthreads) there is no error:
a + b = 2
Discovered by @joelburton in https://github.com/curiousdannii/remglk-rs/pull/11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with the wasm32-unknown-emscripten target in its default non-pthreads configuration, then compare Mutex::try_lock behavior with the x64 result described here. The issue names no source file or test; done means the second try_lock produces the expected Err rather than allowing both locks and printing a + b = 2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100