[COMPILER_APITEST] Add a test for collided unwind

This commit is contained in:
Timo Kreuzer 2025-07-11 10:20:13 +03:00
parent 6334168bf5
commit 4d21384d8f

View file

@ -2920,6 +2920,61 @@ static void Test_structs_seh_nested(void)
#endif // _M_IX86
void Test_collided_unwind(void)
{
volatile int Flags = 0;
volatile int Count = 0;
jmp_buf JumpBuffer;
int ret;
#ifdef _M_IX86
unsigned int Registration = __readfsdword(0);
#endif
ret = setjmp(JumpBuffer);
if (ret == 0)
{
_SEH2_TRY
{
_SEH2_TRY
{
_SEH2_TRY
{
Flags |= 1;
*((volatile int*)(LONG_PTR)-1) = 123;
}
_SEH2_FINALLY
{
Count++;
Flags |= 2;
if (Count) // This is to prevent the compiler from optimizing stuff out
longjmp(JumpBuffer, 1);
Flags |= 4;
}
_SEH2_END;
}
_SEH2_FINALLY
{
Count++;
Flags |= 8;
}
_SEH2_END;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Flags |= 16;
}
_SEH2_END;
}
todo_ros ok(Flags == (1 | 2 | 8), "Flags = %x\n", Flags);
todo_ros ok(Count == 2, "Count = %d\n", Count);
#ifdef _M_IX86
todo_ros ok(__readfsdword(0) == Registration, "SEH registration corrupted!\n");
*(unsigned int*)NtCurrentTeb() = Registration;
#endif
}
START_TEST(pseh)
{
#ifdef _M_IX86
@ -2928,6 +2983,7 @@ START_TEST(pseh)
Test_structs_seh_finally();
Test_structs_seh_nested();
#endif
Test_collided_unwind();
const struct subtest testsuite[] =
{