You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a runtime of thread-per-core model, mostly we works like running multiple independent threads in parallel. So we implemented it in a non-thread-safe way. For example, when maintaining refcount of task, we use UnsafeCell<usize>.
There are 2 problems here:
There is no non-Send + non-Sync version of Waker / RawWakerVTable. As the document of RawWakerVTable, all 4 functions must be thread safe.
Since Waker and RawWakerVTable are all defined by std library and they impl Send and Sync, so we cannot restrict users not pass them between threads. Even we can tell users not pass them, this is not a rusty way. We'd better let it crash on compiling or running, or, we have to make it really thread-safe.
We support a sync feature which implemented by passing waker that not belongs to current thread. This solves task execution problem on thread-per-core way, but the implementation itself is not thread safe. We have to transfrom the state in atomic way. The problems comes from the task module too, the same as the first problem. I believe problem create a VTable (raw_waker) in a thread 2 and call (wake_by_val) in thread 1 #117 is triggered by this problem.
So as a user, if you do not await across threads, you are not affected by the issue. The issue will be fixed soon.
The text was updated successfully, but these errors were encountered:
I made a proposal here that I believe would benefit you. Sadly, it hasn't received a lot of attention. I would really appreciate if you could comment your thoughts on it.
As a runtime of thread-per-core model, mostly we works like running multiple independent threads in parallel. So we implemented it in a non-thread-safe way. For example, when maintaining refcount of task, we use
UnsafeCell<usize>
.There are 2 problems here:
Waker
/RawWakerVTable
. As the document ofRawWakerVTable
, all 4 functions must be thread safe.Since
Waker
andRawWakerVTable
are all defined by std library and they impl Send and Sync, so we cannot restrict users not pass them between threads. Even we can tell users not pass them, this is not a rusty way. We'd better let it crash on compiling or running, or, we have to make it really thread-safe.sync
feature which implemented by passing waker that not belongs to current thread. This solves task execution problem on thread-per-core way, but the implementation itself is not thread safe. We have to transfrom the state in atomic way. The problems comes from thetask
module too, the same as the first problem. I believe problem create a VTable (raw_waker) in a thread 2 and call (wake_by_val) in thread 1 #117 is triggered by this problem.So as a user, if you do not await across threads, you are not affected by the issue. The issue will be fixed soon.
The text was updated successfully, but these errors were encountered: