forked from OSchip/llvm-project
[ORC] Propagate out-of-band errors in callAsync.
Returned out-of-band errors should be wrapped as llvm::Errors and passed to the SendDeserializedResult function. Failure to do this results in an assertion when we try to deserialize from the WrapperFunctionResult while it's in the out-of-band error state.
This commit is contained in:
parent
2a2a37d972
commit
8abf46d39a
|
@ -492,6 +492,12 @@ public:
|
|||
RetT RetVal = detail::ResultDeserializer<SPSRetTagT, RetT>::makeValue();
|
||||
detail::ResultDeserializer<SPSRetTagT, RetT>::makeSafe(RetVal);
|
||||
|
||||
if (auto *ErrMsg = R.getOutOfBandError()) {
|
||||
SDR(make_error<StringError>(ErrMsg, inconvertibleErrorCode()),
|
||||
std::move(RetVal));
|
||||
return;
|
||||
}
|
||||
|
||||
SPSInputBuffer IB(R.data(), R.size());
|
||||
if (auto Err = detail::ResultDeserializer<SPSRetTagT, RetT>::deserialize(
|
||||
RetVal, R.data(), R.size()))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
|
||||
#include "llvm/ADT/FunctionExtras.h"
|
||||
#include "llvm/Testing/Support/Error.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <future>
|
||||
|
@ -142,3 +143,19 @@ TEST(WrapperFunctionUtilsTest, WrapperFunctionCallAndHandleAsyncRet) {
|
|||
addAsyncWrapper, Result, 1, 2));
|
||||
EXPECT_EQ(Result, (int32_t)3);
|
||||
}
|
||||
|
||||
static WrapperFunctionResult failingWrapper(const char *ArgData,
|
||||
size_t ArgSize) {
|
||||
return WrapperFunctionResult::createOutOfBandError("failed");
|
||||
}
|
||||
|
||||
void asyncFailingWrapperCaller(unique_function<void(WrapperFunctionResult)> F,
|
||||
const char *ArgData, size_t ArgSize) {
|
||||
F(failingWrapper(ArgData, ArgSize));
|
||||
}
|
||||
|
||||
TEST(WrapperFunctionUtilsTest, WrapperFunctionCallFailingAsync) {
|
||||
WrapperFunction<void()>::callAsync(asyncFailingWrapperCaller, [](Error Err) {
|
||||
EXPECT_THAT_ERROR(std::move(Err), Failed());
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue