From d5fb0d8bdca0be539a693cb54400d9f9f0ada811 Mon Sep 17 00:00:00 2001 From: Xiaoxuan Meng Date: Fri, 27 Sep 2024 15:55:51 -0700 Subject: [PATCH] Remove the task from the task list at the end of task destruction (#11117) Summary: Pull Request resolved: https://github.com/facebookincubator/velox/pull/11117 Previously the running task counter is decremented as part of member destruction. Recent changes to track the running task in a global list for stats tracking but we remove it from the list at the entry of the task destructor so there is race condition between the task destruction thread running at the background and the test shutdown thread. The fix is to move the task list remove at the end of task destructor. Also note that we manually destroy class members in task destructor so it is fine to remove the task list in destructor. Reviewed By: spershin Differential Revision: D63546925 fbshipit-source-id: 1fe0c8f087a06138035b4d4ef16848faf87d652d --- velox/exec/Task.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/velox/exec/Task.cpp b/velox/exec/Task.cpp index 61b44d9789be..4fba62147af5 100644 --- a/velox/exec/Task.cpp +++ b/velox/exec/Task.cpp @@ -308,8 +308,9 @@ Task::Task( } Task::~Task() { - removeFromTaskList(); - + SCOPE_EXIT { + removeFromTaskList(); + }; // TODO(spershin): Temporary code designed to reveal what causes SIGABRT in // jemalloc when destroying some Tasks. std::string clearStage;