From 649072d1c8aebe9c4b2b952e58ae25c52e666589 Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Fri, 2 Oct 2020 22:27:24 +0200 Subject: [PATCH] vcruntime140_1: Terminate on noexcept function trying to propagate exception. Signed-off-by: Daniel Lehman Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/vcruntime140_1/except_x86_64.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/vcruntime140_1/except_x86_64.c b/dlls/vcruntime140_1/except_x86_64.c index f66ae43721f..a5a760b7b08 100644 --- a/dlls/vcruntime140_1/except_x86_64.c +++ b/dlls/vcruntime140_1/except_x86_64.c @@ -657,6 +657,17 @@ static inline _se_translator_function get_se_translator(void) return __current_exception()[-2]; } +static void check_noexcept( PEXCEPTION_RECORD rec, const cxx_function_descr *descr ) +{ + if (!(descr->header & FUNC_DESCR_IS_CATCH) && + rec->ExceptionCode == CXX_EXCEPTION && + (descr->header & FUNC_DESCR_NO_EXCEPT)) + { + ERR("noexcept function propagating exception\n"); + terminate(); + } +} + static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame, CONTEXT *context, DISPATCHER_CONTEXT *dispatch, const cxx_function_descr *descr, int trylevel) @@ -683,7 +694,11 @@ static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame, cxx_local_unwind4(orig_frame, dispatch, descr, trylevel, last_level); return ExceptionContinueSearch; } - if (!descr->tryblock_map) return ExceptionContinueSearch; + if (!descr->tryblock_map) + { + check_noexcept(rec, descr); + return ExceptionContinueSearch; + } if (rec->ExceptionCode == CXX_EXCEPTION) { @@ -733,6 +748,7 @@ static DWORD cxx_frame_handler4(EXCEPTION_RECORD *rec, ULONG64 frame, } find_catch_block4(rec, context, NULL, frame, dispatch, descr, exc_type, orig_frame, trylevel); + check_noexcept(rec, descr); return ExceptionContinueSearch; } @@ -759,7 +775,7 @@ EXCEPTION_DISPOSITION __cdecl __CxxFrameHandler4(EXCEPTION_RECORD *rec, return ExceptionContinueSearch; /* handle only c++ exceptions */ if (descr.header & ~(FUNC_DESCR_IS_CATCH | FUNC_DESCR_UNWIND_MAP | - FUNC_DESCR_TRYBLOCK_MAP | FUNC_DESCR_EHS)) + FUNC_DESCR_TRYBLOCK_MAP | FUNC_DESCR_EHS | FUNC_DESCR_NO_EXCEPT)) { FIXME("unsupported flags: %x\n", descr.header); return ExceptionContinueSearch;