tests: guest_floating_point fails at random on AMD hosts: "feholdexcept workers preserve the main environment" #10899

Closed
opened 2026-10-25 08:21:46 +00:00 by TechLevelZero · 0 comments
TechLevelZero commented 2026-10-25 08:21:46 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by TechLevelZero on 2026-10-25T08:21:46Z.


What happens
guest_floating_point aborts in roughly a quarter to a third of runs on an AMD EPYC host, even with the machine idle:

floating-point environment: feholdexcept workers preserve the main environment

The check (core/libs/tests/GuestFloatingPoint.cpp:331) compares all 28 bytes of the fnstenv image from before the two worker threads with the image after join. That includes the last x87 instruction pointer, its selector and opcode, and the last operand pointer and its selector (words 3 to 6). AMD CPUs only save those when an x87 exception is pending, so when the main thread is switched out during join and its state is restored, they come back as zero. The control, status and tag words and MXCSR, which are what the workers could affect, are unchanged.

Logged from an instrumented build, on a failing run:

x87[0] ffff037f ffff037f
x87[1] ffff0000 ffff0000
x87[2] ffffffff ffffffff
x87[3] 6fb31f26 00000000
x87[4] 039c0033 00000000
x87[5] a42e16a0 00000000
x87[6] ffff002b ffff0000
sse 00001f80 00001f80

Title, test or build step
ctest guest_floating_point. It failed 47 of 200 rounds of the full suite.

AnyPS5 commit
main 25c1aa1e79; the test is unchanged on 2742004ed2.

System
AMD EPYC 7281 (Zen 1), Proxmox VM with 56 vCPUs, Ubuntu 24.04, GCC 14.2.0, Release.

Steps to reproduce
Run build/tests/guest_floating_point_tests build/core/libs/libs/unpatched/libc.prx 300 times in a loop.

Fix
The branch fix/floating-point-thread-check-fpu-pointers compares only words 0 to 2 and MXCSR at that check. CheckHold still checks that feholdexcept itself keeps the pointer state (line 254).

300 runs in a loop, same machine failed
main 90 / 300
branch 0 / 300
branch, main thread's rounding changed before the check (negative control) 50 / 50
branch, main thread's MXCSR flush-to-zero changed before the check (negative control) 50 / 50

tools/check_conventions.py passes and tools/pr_overlap.py finds no overlap. I'll open it as a pull request once my first one is merged (open-PR limit).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6022397098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10899). Originally posted by [TechLevelZero](https://github.com/TechLevelZero) on 2026-10-25T08:21:46Z. --- **What happens** `guest_floating_point` aborts in roughly a quarter to a third of runs on an AMD EPYC host, even with the machine idle: ``` floating-point environment: feholdexcept workers preserve the main environment ``` The check (`core/libs/tests/GuestFloatingPoint.cpp:331`) compares all 28 bytes of the `fnstenv` image from before the two worker threads with the image after `join`. That includes the last x87 instruction pointer, its selector and opcode, and the last operand pointer and its selector (words 3 to 6). AMD CPUs only save those when an x87 exception is pending, so when the main thread is switched out during `join` and its state is restored, they come back as zero. The control, status and tag words and MXCSR, which are what the workers could affect, are unchanged. Logged from an instrumented build, on a failing run: ``` x87[0] ffff037f ffff037f x87[1] ffff0000 ffff0000 x87[2] ffffffff ffffffff x87[3] 6fb31f26 00000000 x87[4] 039c0033 00000000 x87[5] a42e16a0 00000000 x87[6] ffff002b ffff0000 sse 00001f80 00001f80 ``` **Title, test or build step** ctest `guest_floating_point`. It failed 47 of 200 rounds of the full suite. **AnyPS5 commit** `main` `25c1aa1e79`; the test is unchanged on `2742004ed2`. **System** AMD EPYC 7281 (Zen 1), Proxmox VM with 56 vCPUs, Ubuntu 24.04, GCC 14.2.0, Release. **Steps to reproduce** Run `build/tests/guest_floating_point_tests build/core/libs/libs/unpatched/libc.prx` 300 times in a loop. **Fix** The branch [`fix/floating-point-thread-check-fpu-pointers`](https://github.com/TechLevelZero/AnyPS5/tree/fix/floating-point-thread-check-fpu-pointers) compares only words 0 to 2 and MXCSR at that check. `CheckHold` still checks that `feholdexcept` itself keeps the pointer state (line 254). | 300 runs in a loop, same machine | failed | | --- | --- | | `main` | 90 / 300 | | branch | 0 / 300 | | branch, main thread's rounding changed before the check (negative control) | 50 / 50 | | branch, main thread's MXCSR flush-to-zero changed before the check (negative control) | 50 / 50 | `tools/check_conventions.py` passes and `tools/pr_overlap.py` finds no overlap. I'll open it as a pull request once my first one is merged (open-PR limit). AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#10899
No description provided.