test(libc): run the feupdateenv checks on macOS and under Rosetta 2 #10903
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10903"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-25T08:45:11Z.
What
All 19
guest_update_env*tests fail on macOS. Two host differences cause it, and neither is infeupdateenv:errnoafter the null check. The test checks thatfeupdateenv(nullptr)throws without changingerrno. On macOS it readsENOENTafterwards. The first time a process builds astd::logic_error, Apple's libc++ looks up/usr/lib/libstdc++.6.dylibwith a no-loaddlopen, and that failed lookup leaveserrnoatENOENT. Later ones don't touch it. A five-line program shows the same thing, both native arm64 and x86-64 under Rosetta 2:errno = 123; { std::invalid_argument e("x"); }leaves 2, and the second time it leaves 123. The test now builds onestd::invalid_argumenton macOS before the checks, so the null check sees only whatfeupdateenvdoes.Floating-point traps under Rosetta 2. Rosetta 2 keeps the six MXCSR exception masks set (
_mm_setcsrwith a mask cleared reads back0x1f80) and raises no floating-point trap, x87 included. A program that unmasks the x87 divide-by-zero and runsfdivby zero gets noSIGFPE. So:MasksAndThreadsnow expects the SSE masks the host keeps;guest_update_env_pending_*tests exit 77 on such a host (SKIP_RETURN_CODE 77), because the trap they wait for can't come.Both use a copy of the probe
GuestFloatingPoint.cpphas for the same Rosetta behaviour (HostKeepsSseTraps, whichmaingot in mugurc's100148f762). On a host that keeps an unmasked MXCSR exception, which includes every Linux and Windows x86-64 machine, the expectations and the pending tests are unchanged.A new
docs/dev/debt/libc.mdentry forfeupdateenvrecords that it raises no trap under Rosetta 2 and that the pending-trap tests are skipped there, next to the existing Rosetta entry for the trap-enable functions.Tested
Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 Release under Rosetta 2 (
-DCMAKE_OSX_ARCHITECTURES=x86_64,BUILD_TESTING=ON).mainalone doesn't build libc's tests on macOS, so the tree ismain61fc572ceeplus the open macOS build PRs and the parts of mugurc's series that #7201 also carries.ctest -R '^guest_update_env':guest_update_envfails withnull rejected without state or errno change, and thepending_*tests fail because no trap comes (pending_0_0:enabled pending exception did not trap during feupdateenv).guest_update_envpasses, including the 262144-combination matrix and the thread checks. The 18pending_*tests are reported as skipped.errno2 instead of 123.Not run on Linux or Windows. There
HostKeepsSseTrapsis true and the__APPLE__line isn't compiled, so the test runs as before.check_conventions.py --base upstream/mainpasses.pr_overlap.pyreports no conflicting lines. None of the pull requests it couldn't compare touchesfeupdateenv, its test or its debt entry.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T09:26:46Z.
Review: APPROVED
Reviewed head 06cf0620906ee14689418941c036868fc524da9d. The macOS-only errno prime and the Rosetta trap-capability probe are scoped to the host differences described; the same
HostKeepsSseTrapsprobe already exists inGuestFloatingPoint.cppon main. The explicit test skip code is configured asSKIP_RETURN_CODE 77, so the 18 pending-trap cases report skipped on Rosetta instead of false failures. The independent M1 Pro report confirmsguest_update_envpasses 3/3 and the pending cases skip 3/3 under Rosetta, with the null-invalid_argumenterrno behavior reproduced natively and under Rosetta. Hosted enabled checks all pass, including macOS arm64/x86_64 relinker, register-context, write-watch and ASan; Linux/Windows product jobs are skipped by policy for this test-only diff. Locally,git diff --checkandpython3 tools/check_conventions.py --base upstream/main --head refs/remotes/upstream/pr-10903pass. I did not run the guest test locally; the report’s full test run is contributor-provided. AI-assisted: yes.Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-26T23:36:21Z.
Review: APPROVED
The changed lines are the same as at
06cf062090; the only difference is the rebase onto #11177, which takes care of the conflict @orezraey pointed out. On macOS under Rosetta 2,guest_update_envnow passes,DefaultEnvironmentincluded, and the 18 pending tests are skipped. Approving.Tested on Apple M1 Pro, macOS 27.0.1 (x86_64 Release build under Rosetta 2, Apple clang 21)
Applied at
5556444f2bto mugurc's macOS series (27e968974) merged withmainat2742004ed2, plus main's #11177 (__fe_dfl_env, which this head is rebased on) and other open macOS fixes, then toggled only this PR.ctest -R '^guest_update_env', 3 runs each way:guest_update_envguest_update_env_pending_*feupdateenv: null rejected without state or errno change(the 262144-combination matrix passes first)enabled pending exception did not trap during feupdateenvDefaultEnvironment(restored.mxcsr==0x9fc0, so Rosetta keeps FZ and DAZ)the host keeps no unmasked floating-point exception)The x87 claim that was unchecked in my last report now holds here too. A standalone x86_64 program unmasks the x87 divide-by-zero with
fldcw, then runsfdivby zero andfwait. Under Rosetta 2 it gets noSIGFPE, and the status word reads0x0004.Not checked here: Linux or Windows on this head (ycbuzi's Windows run was on
06cf062090).Notes (none blocking)
core/libs/tests/GuestUpdateEnv.cpp:244: all 18 pending tests wait for an x87 trap.Pendingunmasks onlyx87[0]bitbitand keeps the MXCSR masks at0x3f<<7for everysource, but the skip is decided byHostKeepsSseTraps, which probes MXCSR bit 7. On Rosetta 2 both properties fail together (see above), so the result is right here. A host that pins the MXCSR masks but delivers x87 traps would lose these tests without a failure, though. Probing what the tests need (an unmasked x87 flag raisingSIGFPEatfwait) would close that gap. So would a skip message that names the SSE probe as the reason for the skip.docs/dev/debt/libc.md:30: the new bullet qualifies thefeupdateenv, __fe_dfl_envbullet just above it ("an unmasked pending flag traps"). You could merge the Rosetta sentence into that bullet instead. A separate bullet also matches the Rosetta entry for the trap-enable functions on line 26, so it's fine either way.PR body, What item 2: "Both use the probe
GuestFloatingPoint.cppalready has (HostKeepsSseTraps, from mugurc's24d98f2e1a)". The PR adds a second copy of the probe atGuestUpdateEnv.cpp:45, next toGuestFloatingPoint.cpp:214, and24d98f2e1ais not inmain. The commit inmainthat added it is100148f762. Something like "copies the probe fromGuestFloatingPoint.cpp(mugurc,100148f762)" would match the code.AI-assisted: yes (Claude Code applied the PR, ran the tests, read the code and wrote this review).