Repository navigation
Keep the current task per thread on WASIp3 - #1792
Conversation
`wasip3_task_set` stored the current task in a plain global. With cooperative threads, a thread that runs while another thread is suspended inside a poll reads and overwrites that thread's current task. On WASIp3, `wasip3_task_set` is now defined in the WASIp3 TLS helper, with `WASIP3_TASK` as `_Thread_local`, so each thread with its own TLS block has its own current task. Other targets keep the MVP build with a plain global, since compiling `_Thread_local` as MVP marks the object as incompatible with shared memory. `wasip3_task_set` is a weak symbol, so a component that also links an older version of `wit-bindgen` can still end up with that version's definition.
alexcrichton
left a comment
There was a problem hiding this comment.
I think this might work if the previous definition got the _Thread_local added, avoiding the need for the duplicate function here. Would that work for your use case?
|
Unfortunately that doesn't work as such, no: I can instead add |
|
I should also note that this particular issue isn't blocking my current work. I encountered it while working on a separate fix, and it seemed like something we'll run into soon enough. |
alexcrichton
left a comment
There was a problem hiding this comment.
Good points! And makes sense yeah
wasip3_task_setstored the current task in a plain global. With cooperative threads, a thread that runs while another thread is suspended inside a poll reads and overwrites that thread's current task.On WASIp3,
wasip3_task_setis now defined in the WASIp3 TLS helper, withWASIP3_TASKas_Thread_local, so each thread with its own TLS block has its own current task.Other targets keep the MVP build with a plain global, since compiling
_Thread_localas MVP marks the object as incompatible with shared memory.wasip3_task_setis a weak symbol, so a component that also links an older version ofwit-bindgencan still end up with that version's definition.