[Orc] Fix iterator usage after remove
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>
Wed, 6 Nov 2019 22:11:12 +0000 (17:11 -0500)
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>
Wed, 6 Nov 2019 22:17:27 +0000 (17:17 -0500)
Differential Revision: https://reviews.llvm.org/D69805

llvm/lib/ExecutionEngine/Orc/Core.cpp

index 5c7d888c2d6e19da4f95516be6b689c6cde377f8..9e024ba0f10f8dbd806f216c74d67e388756d971 100644 (file)
@@ -1228,11 +1228,14 @@ void JITDylib::notifyFailed(FailedSymbolsWorklist Worklist) {
       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");