Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Postpone the destruction of Task::current_activity_.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 6 Jun 2023 09:48:30 +0000 (11:48 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 6 Jun 2023 09:59:50 +0000 (11:59 +0200)
Fixes heap-use-after-free spotted by ASan and valgrind.

include/simgrid/plugins/task.hpp
src/plugins/task.cpp

index bf8609d..62eb12a 100644 (file)
@@ -42,6 +42,7 @@ protected:
   int queued_execs_ = 0;
   int count_        = 0;
   bool working_     = false;
+  s4u::ActivityPtr previous_activity_;
   s4u::ActivityPtr current_activity_;
   xbt::signal<void(Task*)> on_this_start_;
   xbt::signal<void(Task*)> on_this_end_;
index c84f83d..dca0c90 100644 (file)
@@ -82,6 +82,8 @@ void Task::complete()
   count_++;
   on_this_end_(this);
   Task::on_end(this);
+  if (current_activity_)
+    previous_activity_ = std::move(current_activity_);
   for (auto const& t : successors_)
     t->receive(this);
   if (ready_to_run())