Commit c884e823 authored by Tobias Koppers's avatar Tobias Koppers

Fix potential deadlock by dropping task_cache read lock before connect_child

The DashMap::get() returns a Ref guard that holds a read lock. Previously,
this lock was held while calling ConnectChildOperation::run, which could
lead to a deadlock. Explicitly drop the reference before proceeding.
parent a0ee1b82
...@@ -1532,8 +1532,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1532,8 +1532,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
// Create a single ExecuteContext for both lookup and connect_child // Create a single ExecuteContext for both lookup and connect_child
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
// First check if the task exists in the cache which only uses a read lock // First check if the task exists in the cache which only uses a read lock
if let Some(task_id) = self.task_cache.get(&task_type) { if let Some(task_id_ref) = self.task_cache.get(&task_type) {
let task_id = *task_id; let task_id = *task_id_ref;
drop(task_id_ref);
self.track_cache_hit(&task_type); self.track_cache_hit(&task_type);
operation::ConnectChildOperation::run( operation::ConnectChildOperation::run(
parent_task, parent_task,
...@@ -1615,8 +1616,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1615,8 +1616,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
} }
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
// First check if the task exists in the cache which only uses a read lock // First check if the task exists in the cache which only uses a read lock
if let Some(task_id) = self.task_cache.get(&task_type) { if let Some(task_id_ref) = self.task_cache.get(&task_type) {
let task_id = *task_id; let task_id = *task_id_ref;
drop(task_id_ref);
self.track_cache_hit(&task_type); self.track_cache_hit(&task_type);
operation::ConnectChildOperation::run( operation::ConnectChildOperation::run(
parent_task, parent_task,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment