fix: run_task/deactivate_task race condition on m_imp->m_closure (#2959)
Fixes #2853, unblocking my work before I get to refactoring this part of the task manager.
This commit is contained in:
parent
b120080b85
commit
78200b309f
1 changed files with 5 additions and 1 deletions
|
|
@ -714,8 +714,12 @@ class task_manager {
|
|||
resolve_core(t, v);
|
||||
} else {
|
||||
// `bind` task has not finished yet, re-add as dependency of nested task
|
||||
// NOTE: closure MUST be extracted before unlocking the mutex as otherwise
|
||||
// another thread could deactivate the task and empty `m_clousure` in
|
||||
// between.
|
||||
object * c = t->m_imp->m_closure;
|
||||
lock.unlock();
|
||||
add_dep(lean_to_task(closure_arg_cptr(t->m_imp->m_closure)[0]), t);
|
||||
add_dep(lean_to_task(closure_arg_cptr(c)[0]), t);
|
||||
lock.lock();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue