Skip to content

Conversation

@Milek7
Copy link
Contributor

@Milek7 Milek7 commented Feb 7, 2024

TID returned by wasi_thread_spawn must be non-zero and upper three bits must always be zero: https://github.com/WebAssembly/wasi-threads?tab=readme-ov-file#design-choice-thread-ids

Current implementation didn't fulfill this requirements, only clearing the top bit from random value. This breaks wasi-libc mutexes when random TID is larger or equal to 0x3FFFFFFF.

Additionally, from birthday paradox probability of collision in allowed TID range nears 50% after spawning 27000 threads. This is large but not totally impossible, thus replace random generation with sequential allocation.

@Milek7 Milek7 requested a review from a team as a code owner February 7, 2024 13:52
@Milek7 Milek7 requested review from pchickey and removed request for a team February 7, 2024 13:52
@pchickey pchickey requested review from abrown and removed request for pchickey February 7, 2024 17:47
@abrown abrown added this pull request to the merge queue Feb 12, 2024
@abrown
Copy link
Member

abrown commented Feb 12, 2024

@Milek7, thanks for the PR!

Merged via the queue into bytecodealliance:main with commit 9d487c5 Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants