diff --git a/libraries/wasm-jit/Source/Runtime/WAVMIntrinsics.cpp b/libraries/wasm-jit/Source/Runtime/WAVMIntrinsics.cpp index a85d0e21fcd..9e38eeebea0 100644 --- a/libraries/wasm-jit/Source/Runtime/WAVMIntrinsics.cpp +++ b/libraries/wasm-jit/Source/Runtime/WAVMIntrinsics.cpp @@ -9,9 +9,14 @@ namespace Runtime { static void causeIntrensicException(Exception::Cause cause) { - Platform::immediately_exit(std::make_exception_ptr(Exception{cause, std::vector()})); + try { + Platform::immediately_exit(std::make_exception_ptr(Exception{cause, std::vector()})); + } + catch (...) { + Platform::immediately_exit(std::current_exception()); + } __builtin_unreachable(); - } + } template Float quietNaN(Float value) @@ -145,19 +150,24 @@ namespace Runtime DEFINE_INTRINSIC_FUNCTION3(wavmIntrinsics,indirectCallSignatureMismatch,indirectCallSignatureMismatch,none,i32,index,i64,expectedSignatureBits,i64,tableBits) { - TableInstance* table = reinterpret_cast(tableBits); - void* elementValue = table->baseAddress[index].value; - const FunctionType* actualSignature = table->baseAddress[index].type; - const FunctionType* expectedSignature = reinterpret_cast((Uptr)expectedSignatureBits); - std::string ipDescription = ""; - LLVMJIT::describeInstructionPointer(reinterpret_cast(elementValue),ipDescription); - Log::printf(Log::Category::debug,"call_indirect signature mismatch: expected %s at index %u but got %s (%s)\n", - asString(expectedSignature).c_str(), - index, - actualSignature ? asString(actualSignature).c_str() : "nullptr", - ipDescription.c_str() - ); - causeIntrensicException(elementValue == nullptr ? Exception::Cause::undefinedTableElement : Exception::Cause::indirectCallSignatureMismatch); + try { + TableInstance* table = reinterpret_cast(tableBits); + void* elementValue = table->baseAddress[index].value; + const FunctionType* actualSignature = table->baseAddress[index].type; + const FunctionType* expectedSignature = reinterpret_cast((Uptr)expectedSignatureBits); + std::string ipDescription = ""; + LLVMJIT::describeInstructionPointer(reinterpret_cast(elementValue),ipDescription); + Log::printf(Log::Category::debug,"call_indirect signature mismatch: expected %s at index %u but got %s (%s)\n", + asString(expectedSignature).c_str(), + index, + actualSignature ? asString(actualSignature).c_str() : "nullptr", + ipDescription.c_str() + ); + causeIntrensicException(elementValue == nullptr ? Exception::Cause::undefinedTableElement : Exception::Cause::indirectCallSignatureMismatch); + } + catch (...) { + Platform::immediately_exit(std::current_exception()); + } } DEFINE_INTRINSIC_FUNCTION0(wavmIntrinsics,indirectCallIndexOutOfBounds,indirectCallIndexOutOfBounds,none)