[PATCH] D69805: [Orc] Fix iterator usage after remove

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 08:16:51 PST 2019


aganea created this revision.
aganea added a reviewer: lhames.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

The test `[OrcJITTests]CoreAPIsStandardTest.FailureInDependency` previously failed on a Debug build on Windows with `_ITERATOR_DEBUG_LEVEL 
 == 2`. This was caused by the list being iterated (`MII->second.pendingQueries()`) to be modifed by `JITDylib::MaterializingInfo::removeQuery()` (called by `Q->detach()`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69805

Files:
  llvm/lib/ExecutionEngine/Orc/Core.cpp


Index: llvm/lib/ExecutionEngine/Orc/Core.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -1228,11 +1228,14 @@
       MI.UnemittedDependencies.clear();
 
       // Collect queries to be failed for this MII.
+      AsynchronousSymbolQueryList ToDetach;
       for (auto &Q : MII->second.pendingQueries()) {
         // Add the query to the list to be failed and detach it.
         FailedQueries.insert(Q);
-        Q->detach();
+        ToDetach.push_back(Q);
       }
+      for (auto &Q : ToDetach)
+        Q->detach();
 
       assert(MI.Dependants.empty() &&
              "Can not delete MaterializingInfo with dependants still attached");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69805.227711.patch
Type: text/x-patch
Size: 756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191104/b0bd598e/attachment.bin>


More information about the llvm-commits mailing list