From 007d173e2e0c29903bc17a9d5108f531a6f2ea4d Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 6 Nov 2019 17:11:12 -0500 Subject: [PATCH] [Orc] Fix iterator usage after remove Differential Revision: https://reviews.llvm.org/D69805 --- llvm/lib/ExecutionEngine/Orc/Core.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index 5c7d888c2d6e..9e024ba0f10f 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -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");