-
-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current thread_id changing after suspending in direct execution #6333
Comments
@Pansysk75 Yep, that's caused by the direct execution patch. cancelable_action should call
|
I just realized that we don't have that - what an oversight! It should be added here:
hpx/libs/core/threading/src/thread.cpp Lines 386 to 389 in bc993dd
The new code should be: thread::id get_outer_id() noexcept
{
return thread::id(threads::get_outer_self_id());
} |
That should work, but as a user I would really wonder what "outer" refers to and why I should use that (if I didn't know the implementation details). |
Alternatively we could make the current implementation of |
Background
@hkaiser I came across this issue while investigating the current hangs in
cancelable_action
test.In that test, the current thread_id is firstly obtained using
hpx::this_thread::get_id()
(through areset_id
helper object).Then, we have a workloop that occasionally suspends, waiting to be interrupted (
hpx::thread::interrupt(id_)
).hpx/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp
Lines 81 to 94 in bc993dd
Issue
I found that calling
hpx::this_thread::get_id()
before and afterhpx::this_thread::suspend()
would often return a different id.I believe this is due to the way yielding is handled when utilizing direct execution:
hpx/libs/core/coroutines/include/hpx/coroutines/detail/coroutine_stackful_self_direct.hpp
Lines 34 to 39 in bc993dd
coroutine_stackful_self_direct
falls back tonext_self_
(its calling context) for yielding, which will fail to correctly restore the state after yielding:hpx/libs/core/coroutines/include/hpx/coroutines/detail/coroutine_stackful_self.hpp
Lines 32 to 42 in bc993dd
If I understand correctly,
reset_self_on_exit
will cause the static variablelocal_self_
to refer to the "simple" (coroutine_stackful_self
) coroutine after yielding (and not to the direct coroutine where it used to before the yield, see the use ofreset_self_on_exit
oncoroutine_impl::invoke_directly()
).The solution is probably simple, but I just barely got to understanding how these coroutines work, so I just hope I got things right fttb.
The text was updated successfully, but these errors were encountered: