llvm.org GIT mirror llvm / c836cd7
[ORC] Remove query dependencies when symbols are resolved. If the dependencies are not removed then a late failure (one symbol covered by the query failing after others have already been resolved) can result in an attempt to detach the query from already finalized symbol, resulting in an assert/crash. This patch fixes the issue by removing query dependencies in JITDylib::resolve for symbols that meet the required state. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369809 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 23 days ago
2 changed file(s) with 26 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
10301030 auto &MI = MaterializingInfos[Name];
10311031 for (auto &Q : MI.takeQueriesMeeting(SymbolState::Resolved)) {
10321032 Q->notifySymbolMetRequiredState(Name, ResolvedSym);
1033 Q->removeQueryDependence(*this, Name);
10331034 if (Q->isComplete())
10341035 CompletedQueries.insert(std::move(Q));
10351036 }
934934 }
935935 }
936936
937 TEST_F(CoreAPIsStandardTest, FailEmissionEarly) {
937 TEST_F(CoreAPIsStandardTest, FailEmissionAfterResolution) {
938938
939939 cantFail(JD.define(absoluteSymbols({{Baz, BazSym}})));
940940
969969 << "Unexpected success while trying to test error propagation";
970970 }
971971
972 TEST_F(CoreAPIsStandardTest, FailAfterPartialResolution) {
973
974 cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
975
976 // Fail materialization of bar.
977 auto BarMU = std::make_unique(
978 SymbolFlagsMap({{Bar, BarSym.getFlags()}}),
979 [&](MaterializationResponsibility R) { R.failMaterialization(); });
980
981 cantFail(JD.define(std::move(BarMU)));
982
983 bool QueryHandlerRun = false;
984 ES.lookup(
985 JITDylibSearchList({{&JD, false}}), SymbolNameSet({Foo, Bar}),
986 SymbolState::Resolved,
987 [&](Expected Result) {
988 EXPECT_THAT_EXPECTED(std::move(Result), Failed())
989 << "Expected query to fail";
990 QueryHandlerRun = true;
991 },
992 NoDependenciesToRegister);
993 EXPECT_TRUE(QueryHandlerRun) << "Query handler never ran";
994 }
995
972996 TEST_F(CoreAPIsStandardTest, TestLookupWithUnthreadedMaterialization) {
973997 auto MU = std::make_unique(
974998 SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}),