Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#15 from Esri/john4744/fix_inline_race
Browse files Browse the repository at this point in the history
Store task handle before scheduling to avoid potential race with inlining logic
john4744 authored Feb 22, 2024
2 parents 20be602 + c5af5c2 commit da7cda7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Release/include/pplx/pplx.h
Original file line number Diff line number Diff line change
@@ -143,8 +143,11 @@ class _TaskCollectionImpl
}
else
{
_M_pScheduler->schedule(_TaskProcHandle_t::_RunChoreBridge, _PTaskHandle);
// Store the task first before scheduling, otherwise a potential race condition
// could occur between storing _M_scheduled_task here and _M_scheduled_task being
// set to nullptr in _Complete().
_M_scheduled_task.store(_PTaskHandle);
_M_pScheduler->schedule(_TaskProcHandle_t::_RunChoreBridge, _PTaskHandle);
}
}

0 comments on commit da7cda7

Please sign in to comment.