From ff8d24cabb66a1146ae1ca97b77aa593dc4861f0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Mar 2020 15:44:19 +0200 Subject: [PATCH] [PSEH3] Fix _SEH3_LEAVE Previously, when leave was used in the except or finally block of a nested try block, it would jump back to the start of the except/finally block, resulting in an endless loop. This is fixed by jumping back to a label at the beginning of the try block, which is only visible from within the try block itself and from there to the end of the SEH block. Fixes seh0055 testcase of MS SEH tests. --- modules/rostests/apitests/compiler/ms_seh.c | 2 -- sdk/lib/pseh/include/pseh/pseh3.h | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/rostests/apitests/compiler/ms_seh.c b/modules/rostests/apitests/compiler/ms_seh.c index 6656bb7f585..c3b4190654f 100644 --- a/modules/rostests/apitests/compiler/ms_seh.c +++ b/modules/rostests/apitests/compiler/ms_seh.c @@ -147,9 +147,7 @@ START_TEST(ms_seh) run_test(seh0052); run_test(seh0053); run_test(seh0054); -#ifdef _USE_NATIVE_SEH run_test(seh0055); -#endif run_test(seh0056); run_test(seh0057); run_test(seh0058); diff --git a/sdk/lib/pseh/include/pseh/pseh3.h b/sdk/lib/pseh/include/pseh/pseh3.h index c7286e9d7bd..b8aa437589a 100644 --- a/sdk/lib/pseh/include/pseh/pseh3.h +++ b/sdk/lib/pseh/include/pseh/pseh3.h @@ -371,13 +371,18 @@ _Pragma("GCC diagnostic pop") \ volatile SEH3$_REGISTRATION_FRAME _SEH3$_AUTO_CLEANUP _SEH3$_TrylevelFrame; \ \ goto _SEH3$_l_BeforeTry; \ + { \ + __label__ _SEH3$_l_Leave; \ + _SEH3$_l_Leave: (void)0; \ /* Silence warning */ goto _SEH3$_l_AfterTry; \ + /* Silence warning */ goto _SEH3$_l_Leave; \ \ _SEH3$_l_DoTry: \ if (1) #define _SEH3_EXCEPT(...) \ + } \ /* End of the try block */ \ _SEH3$_l_AfterTry: (void)0; \ goto _SEH3$_l_EndTry; \ @@ -422,6 +427,7 @@ _Pragma("GCC diagnostic pop") \ #define _SEH3_FINALLY \ + } \ /* End of the try block */ \ _SEH3$_l_AfterTry: (void)0; \ /* Set ExceptionPointers to 0, this is used by _abnormal_termination() */ \ @@ -471,7 +477,7 @@ _Pragma("GCC diagnostic pop") \ /* Close the outer scope */ \ } -#define _SEH3_LEAVE goto _SEH3$_l_AfterTry +#define _SEH3_LEAVE goto _SEH3$_l_Leave #define _SEH3_VOLATILE volatile