fix(libkernel): inherit floating-point environment on Windows threads #4981
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4981"
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 QRMOE on 2026-10-13T07:14:04Z.
What
Windows guest threads inherit their creator's floating-point environment.
_beginthreadexcurrently resets rounding to nearest, clears exception flags and selects 53-bit x87 precision; for example, a worker'sasinl(0.75L)loses the low mantissa bits even when its creator uses 64-bit precision.Capture
std::fenv_tat creation and restore it immediately before guest entry, after host thread setup. Preserve the caller's settings, including an intentionally selected 53-bit precision mode. Linux continues to use native pthread inheritance. This follows POSIX pthread_create; the SCE entry point shares that path and has not been measured on console. Technical debt records that distinction and the unchanged environment of adopted host threads.Tested
Windows, MinGW GCC 15.2, Release,
BUILD_TESTING=ON, main basec2565f014:asinlprecision.asinl(0.75L)andnearbyint(0.5)with the creator's results. The regression completes in 1.50 seconds.guest_sce_net,guest_poll,guest_socket_read_write,guest_tcp,guest_socket_pair,guest_dup,guest_socket_eventsandguest_fstatfs). Avast logs automatic sandboxing of test programs. The local full-build limitation remains; local full-build success is not claimed.Review validation
After resolving the documentation conflict, the actual uploaded head
6100f51f5passed an explicit libs build and all 14 selected thread/math runtime checks (3.02 seconds total). Patched-library loading also passed (15/15 total relevant checks) after main's unwind helper accessor fix3a9cc6368. No implementation changes were needed to resolve the conflict.xXPBSXx's Windows report: Reports the Windows inheritance test passing with the PR and failing with main's source restored.
Resolved the
docs/dev/debt/libc.mdconflict against main while preserving the newatanhfdocumentation and the thread precision update. The implementation remains independent of thesnprintf/vsnprintfcarry work discussed in the comments.Ready for maintainer review. Full Linux/Windows CI requires a maintainer's manual dispatch; marking this PR ready does not claim those jobs passed.
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 repositoryImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T09:16:31Z.
Windows counter-test: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, this PR merged onto
main2a2a3dc65.guest_pthread_fenvpasses with the PR; with the PR's source files replaced bymain's, same test, it fails (SCE thread did not inherit fenv).Not tested: Linux, a console, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T10:29:29Z.
I am preparing a carry PR for issue #3974 (Windows
snprintf/vsnprintfsize overflow). The code changes are separate, but the current branches conflict indocs/dev/debt/libc.md. I can list #4981 as a merge-order dependency and rebase after it lands. Does that ordering work for you?Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-13T11:12:08Z.
@MarcZX100 Yes, that ordering works for me: merge #4981 first, then rebase #5070 on the updated main. I’ve resolved #4981’s conflict with main and marked it ready for review. The updated head passed the explicit library build and all 15 relevant runtime/loading checks.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T13:13:10Z.
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.
main)docs/dev/debt/libkernel.mdL98docs/dev/debt/libkernel.mdL98Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:34:58Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-15T07:41:36Z.
Understood. I’ll leave this PR closed and hold off on new PRs without a title needing the change. If this is revisited, I’ll bring a title ID and a current-main failure log.
@MarcZX100 Since #4981 is now closed, please don’t wait for it as a merge-order dependency; my earlier proposed ordering no longer applies.
Pull request closed