Skip to content

fix(tests): compare the floating-point exception masks with the ones the host keeps - #8287

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
mugurc:fix/tests-fenv-masks-rosetta
Oct 23, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
mugurc:fix/tests-fenv-masks-rosetta

Conversation

@mugurc

@mugurc mugurc commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

guest_floating_point (#6985) fails on macOS with "flag updates preserve exception masks". The check unmasks the overflow exception in the x87 control word and in MXCSR, calls fesetexceptflag and feclearexcept, and expects both to equal the values it wrote. Under Rosetta 2 the six MXCSR exception masks always read back set, so MXCSR never held the value the test wrote, although the two functions left the masks alone. Part of the macOS series announced on #1 (#1 (comment)).

  • The test now compares with the environment read back after the write. On a host that keeps the write, that is the value written, so the check is the same there; under Rosetta it still checks the x87 mask and the rest of MXCSR.
  • The debt entry for the floating-point functions notes that an SSE exception the guest unmasks stays masked under Rosetta.

The trap checks that #8442 added since fail on macOS for the same reason, the first one with "enable unmasks the SSE exceptions". They unmask exceptions with feenableexcept and its relatives, expect MXCSR to hold the new masks, and expect the enable and disable results to report the traps enabled on both units. Under Rosetta no SSE trap is ever enabled, so MXCSR keeps all six masks and every result reports none. A second commit:

  • asks the host once whether it keeps an unmasked MXCSR exception and, where it does not, expects all six SSE masks set and no trap on both units. On other hosts the expectations are the same as before;
  • adds a debt entry: the trap functions change only the x87 masks under Rosetta.

Tested

macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series. The first commit ran on main 3fd1cc3 with the series (ci/macos-series-2 on my fork), #8279, #8284, the open macOS fixes #7524 and #7937, and three changes from #7332; the second on main 7e2ba73 with the series, which now includes #7937, and the libSceSsl change of #7332. Both commits are now on main cc00785.

  • A probe built for x86-64, run under Rosetta: clearing any one of the six MXCSR mask bits of 0x1f80 reads back 0x1f80. Flush-to-zero with denormals-are-zero (0x9fc0) and rounding mode 3 (0x7f80) read back as written, and so does an x87 control word with the overflow mask cleared (0x0377).
  • guest_floating_point fails without this PR and passes with it, 5 runs of 5, before and after feat(libc): add the floating-point trap controls #8442's trap checks (with the second commit for those).
  • Linux and Windows: not run for the second commit. There the host keeps the unmasked MXCSR exception, so the trap checks expect the same values as before. @ycbuzi ran the first commit on Windows: guest_floating_point passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10175 docs/dev/debt/libc.md L18

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 docs/dev/debt/libc.md
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8306 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9133 docs/dev/debt/libc.md
PR 9408 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9527 docs/dev/debt/libc.md
PR 9552 docs/dev/debt/libc.md
PR 9669 docs/dev/debt/libc.md
PR 9763 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md

@ycbuzi

ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Windows run of 9415d8f merged onto main ec7eacc (6dcb085765, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built guest_floating_point_tests with no errors or warnings; ctest --repeat until-fail:2 on guest_floating_point: passes on both repeats. Not run: Linux.

…the host keeps

Under Rosetta 2 the six MXCSR exception masks always read back set: a
write that unmasks an SSE exception is not kept, while the x87 masks and
the other MXCSR bits are. guest_floating_point unmasked the overflow
exception on both units and then expected MXCSR to equal the value it
wrote, so it failed on macOS although fesetexceptflag and feclearexcept
left the masks alone. The test now compares with the environment read
back after the write, which on other hosts is the value written. The
debt entry for the floating-point functions notes the Rosetta behaviour.
… trap checks

The trap checks unmask exceptions with feenableexcept and its relatives
and expect MXCSR to hold the new masks, and the enable and disable
results to report the traps enabled on both units. Under Rosetta 2
MXCSR keeps its six exception masks set, so no SSE trap is ever enabled
and every result reports none. The test now asks the host once whether
it keeps an unmasked MXCSR exception and, where it does not, expects
all six SSE masks set and no trap on both units; on other hosts the
expectations are the same as before. A debt entry records that the
trap functions change only the x87 masks under Rosetta.
@mugurc
mugurc force-pushed the fix/tests-fenv-masks-rosetta branch from 9415d8f to 100148f Compare October 22, 2026 10:09
@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit dcd40e1 into boykopovar:main Oct 23, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants