From 7371fb422900fc5abf9671f9954b460ac94bc80e Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 23 Aug 2019 20:37:32 +0000 Subject: [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. llvm-svn: 369809 --- .../unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp') diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 729dad9c29a..60612f6c6a7 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -935,7 +935,7 @@ TEST_F(CoreAPIsStandardTest, FailResolution) { } } -TEST_F(CoreAPIsStandardTest, FailEmissionEarly) { +TEST_F(CoreAPIsStandardTest, FailEmissionAfterResolution) { cantFail(JD.define(absoluteSymbols({{Baz, BazSym}}))); @@ -970,6 +970,30 @@ TEST_F(CoreAPIsStandardTest, FailEmissionEarly) { << "Unexpected success while trying to test error propagation"; } +TEST_F(CoreAPIsStandardTest, FailAfterPartialResolution) { + + cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + + // Fail materialization of bar. + auto BarMU = std::make_unique( + SymbolFlagsMap({{Bar, BarSym.getFlags()}}), + [&](MaterializationResponsibility R) { R.failMaterialization(); }); + + cantFail(JD.define(std::move(BarMU))); + + bool QueryHandlerRun = false; + ES.lookup( + JITDylibSearchList({{&JD, false}}), SymbolNameSet({Foo, Bar}), + SymbolState::Resolved, + [&](Expected Result) { + EXPECT_THAT_EXPECTED(std::move(Result), Failed()) + << "Expected query to fail"; + QueryHandlerRun = true; + }, + NoDependenciesToRegister); + EXPECT_TRUE(QueryHandlerRun) << "Query handler never ran"; +} + TEST_F(CoreAPIsStandardTest, TestLookupWithUnthreadedMaterialization) { auto MU = std::make_unique( SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}), -- cgit v1.2.3