From 7ce21df27a02852f76eb728b14ea0cc104fe2b95 Mon Sep 17 00:00:00 2001 From: Maximilian Fleckenstein <166870690+maximilianfv@users.noreply.github.com> Date: Sat, 24 Oct 2026 05:26:46 -0300 Subject: [PATCH] fix(tests): compare the enabled exception query with the environment the host keeps CheckEnabledExceptions writes x87 and MXCSR states with some SSE exceptions unmasked, calls fegetexcept, and expects the environment afterwards to equal the state it wrote. Under Rosetta 2 MXCSR keeps its six exception masks set, as CheckTraps already allows for, so whenever the test unmasks an SSE exception the state read back differs from the one written, and the check failed although fegetexcept changed nothing. Compare with the environment read back right after the write instead; on other hosts the two are the same. Co-Authored-By: Claude Opus 5.5 --- core/libs/tests/GuestFloatingPoint.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/libs/tests/GuestFloatingPoint.cpp b/core/libs/tests/GuestFloatingPoint.cpp index edfaeddf11f..a820043ea0a 100644 --- a/core/libs/tests/GuestFloatingPoint.cpp +++ b/core/libs/tests/GuestFloatingPoint.cpp @@ -70,13 +70,14 @@ void CheckEnabledExceptions() { state.x87[1] = (state.x87[1] & ~0x3fu) | (x87 & 0x15u); state.sse = (state.sse & ~0x7fbfu) | 0x2000 | (sse << 7) | (sse & 0x2au); WriteEnvironment(state); + const auto written = ReadEnvironment(); *__error_nid_postfix() = 123; const int enabled = fegetexcept_nid_postfix(); const int error = *__error_nid_postfix(); const auto after = ReadEnvironment(); WriteEnvironment(seeded); Require(enabled == static_cast(0x3f ^ x87), "enabled exceptions use the x87 masks independently of SSE"); - Require(after.x87[0] == state.x87[0] && after.x87[1] == state.x87[1] && after.sse == state.sse, + Require(after.x87[0] == written.x87[0] && after.x87[1] == written.x87[1] && after.sse == written.sse, "enabled exception query preserves control modes and flags"); Require(error == 123, "enabled exception query preserves errno"); }