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
Reading the code of unlock for the async_mutex, my understanding is that if there's a long list of awaiters currently for the mutex, the mutex's holder's call to unlock will call resume() the first awaiter, whose unlock call will call resume() of the next awaiter and so on and so on, potentially running out of stack space.
This potential situation might be avoided by use of an asynchronous unlock, by which co_await mutex.unlock() would suspend the lock holder, schedule it in some way for later resumption and make the first awaiter be resumed immediately by the symmetric return mechanism of await_suspend(...). Thus there would be chained calls to resume() consuming the stack.
The text was updated successfully, but these errors were encountered:
FunMiles
changed the title
Mutex unlock can potentially overflow the stack. Provide an async unlock to solve the issue.
Mutex unlock can potentially overflow the stack. Provide an async unlock to allow users to avoid the issue.
Feb 9, 2023
is the last statement in that function. It seems to me that no destructors have to be called at the end of this function. I would guess the compiler can do tail-call optimization, thus not needing extra stack space for the call.
It would be very interesting to see whether one can create that stack overflow you are describing.
Reading the code of unlock for the async_mutex, my understanding is that if there's a long list of awaiters currently for the mutex, the mutex's holder's call to unlock will call resume() the first awaiter, whose unlock call will call resume() of the next awaiter and so on and so on, potentially running out of stack space.
This potential situation might be avoided by use of an asynchronous unlock, by which
co_await mutex.unlock()
would suspend the lock holder, schedule it in some way for later resumption and make the first awaiter be resumed immediately by the symmetric return mechanism ofawait_suspend(...)
. Thus there would be chained calls toresume()
consuming the stack.The text was updated successfully, but these errors were encountered: