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
[reported by blelbach][Trac time Sun Oct 23 22:49:24 2011] A threads thread_state_enum and thread_state_ex_enum are both stored in two
separate atomic objects. In threadmanager_impl<>::set_state, these two variables
are assigned independently of each other (e.g. without a third form of synchronization).
This operation is not thread safe; it is possible for another set_thread_state operation
to modify one or both of these values before the first call returns.
The set_thread_state unit test demonstrates this bug. This unit test creates one
target pxthread, which enters an infinite yield loop. Each time this thread is
woken up, it checks the thread_state_ex_enum code that it was woken with. If the
code is wait_signaled or wait_timeout, then it stores this information and yields
again. If the code is wait_terminate, then it prints out the results of the test,
and returns.
In addition to the target thread, a number of worker threads (here, 64) are created
in a recursive tree. Each worker thread performs two set_thread_state operations
in serial. First, it calls set_thread_state(target_thread, pending, wait_signaled).
Then, it calls set_thread_state(target_thread, suspended, wait_timeout).
If changing thread state is an atomic operation, then the target thread should never
be resumed with wait_timeout.
[reported by blelbach] [Trac time Sun Oct 23 22:49:24 2011] A threads thread_state_enum and thread_state_ex_enum are both stored in two
separate atomic objects. In threadmanager_impl<>::set_state, these two variables
are assigned independently of each other (e.g. without a third form of synchronization).
This operation is not thread safe; it is possible for another set_thread_state operation
to modify one or both of these values before the first call returns.
The set_thread_state unit test demonstrates this bug. This unit test creates one
target pxthread, which enters an infinite yield loop. Each time this thread is
woken up, it checks the thread_state_ex_enum code that it was woken with. If the
code is wait_signaled or wait_timeout, then it stores this information and yields
again. If the code is wait_terminate, then it prints out the results of the test,
and returns.
In addition to the target thread, a number of worker threads (here, 64) are created
in a recursive tree. Each worker thread performs two set_thread_state operations
in serial. First, it calls set_thread_state(target_thread, pending, wait_signaled).
Then, it calls set_thread_state(target_thread, suspended, wait_timeout).
If changing thread state is an atomic operation, then the target thread should never
be resumed with wait_timeout.
Note that the number of times actually woken to the number of times scheduled to
be woken is off because of a related but different bug.
The text was updated successfully, but these errors were encountered: