fix(tests): compare x87 pointer words in guest_floating_point only when both images have ES set #10937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10937"
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 TechLevelZero on 2026-10-25T11:09:09Z.
What
guest_floating_pointfailed at random on AMD hosts, as #10899 describes. The test compared whole 28-bytefnstenvimages. Those include the last x87 instruction pointer, its selector and opcode, and the last operand pointer and its selector (words 3 to 6). AMD CPUs save these only while an unmasked exception is pending (status ES bit; AMD64 Programmer's Manual, FXSAVE). So when the thread is switched out between two images, the restored words come back as zero.SameEnvironmentcompares the control, status and tag words and MXCSR. It compares words 3 to 6 only when both images have ES set.SameEnvironmentis used in three checks:feholdexcept saves the full original environment,null feholdexcept preserves the environment, and the check after the worker threads are joined.feholdexcept preserves x87 tags and instruction/data stateis nowfeholdexcept preserves x87 tags.feholdexceptclears ES there (the test checks this), so those pointer words are never guaranteed on AMD.None of the states this test builds has ES set, so in practice the pointer words are no longer compared. Keeping a pointer check that holds on AMD would need a state with ES set and an unmasked exception pending. That would be a separate change.
Fixes #10899.
Tested
guest_floating_point_tests libc.prxin a loop, idle.mainand the branch were built from the same tree (Ubuntu 24.04, GCC 14.2.0, Release):mainnull feholdexcept)Reported on #10899 by others:
main98 / 300, branch 0 / 600. An earlier version that only narrowed the check after the join still failed 2 / 300 there, inCheckHold; this version fixes that.Negative controls, 30 runs each on the EPYC, all failing at the expected check:
null feholdexceptcheck;feholdexceptsaved.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch fix/floating-point-thread-check-fpu-pointersreports no overlap.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T11:22:28Z.
Review: APPROVED
Reviewed exact head
8c058aa. The comparison ignores x87 instruction/data pointer fields unless both environments have ES set, while still comparing control/status/tag and MXCSR; the three whole-environment assertions use this helper, and the hold test no longer asserts pointer fields after feholdexcept clears ES. This narrows the test to state the host guarantees. Local conventions and diff checks passed. The reported AMD/Intel repeated runs are author-reported; hosted product jobs are skipped by path policy.