You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, ftruncate and sceKernelFtruncate with an invalid or closed descriptor reach _chsize_s's invalid-parameter handler. With the default handler this aborts the process instead of returning EBADF.
Reject an invalid native handle before resizing and use the existing thread-local CRT suppression around _chsize_s, preserving the caller's handler. Microsoft documents the invalid-descriptor callback that requires this handling. The regression checks both guest APIs with negative, closed and out-of-range descriptors at zero and nonzero lengths, checks handler restoration, and verifies that the real file is intact. The existing shrinking, extension and permission cases still run.
Tested
I tested on Windows 11 Pro, MinGW-w64 GCC 15.2.0 (WinLibs), Release/Ninja, with BUILD_TESTING=ON, outside the sandbox for the native filesystem cases.
On maind9bfa0f3a, the new regression reports 12 CRT parameter-handler invocations and fails.
With the fix, guest_truncate, guest_filesystem, guest_aio_bad_descriptors and guest_dup pass (4/4, 0.26 s).
After rebasing onto main 8ba869d, full default Windows build, conventions and git diff --check pass.
I checked the complete open PR inventory and the 24 shared-file diffs. The 19 AOT diffs are identical in this file and change macOS paths; the remaining changes cover positioned transfers, append writes, archive-backed descriptors and standard-stream closure. feat: read title files from a read-only app0.zar (ZArchive) layer #5835's archive check in the public ftruncate wrapper does not implement this Windows native-handle fix. The focused repository overlap check is clean.
Linux/macOS and a retail title were not run; production changes are inside the existing Windows branch.
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 in technical debt
No notes, investigation .md files or images added to the repository
New third-party code is a submodule built from source
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.
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.
Checked the diff against the existing WithoutParameterHandler usage in Stdio.cpp and the new GuestTruncate regression (negative, closed and out-of-range descriptors, both guest APIs, handler restored). Build and ctest are green on Linux; the Windows path is covered by the Windows build run before merge. Merging.
Re-checked against current main: the diff still applies cleanly and NativeFtruncate is unchanged by the recent Stdio.cpp merges. Build and ctest are green on Linux (guest_truncate included); the Windows path is covered by the Windows build run before merge. Merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On Windows,
ftruncateandsceKernelFtruncatewith an invalid or closed descriptor reach_chsize_s's invalid-parameter handler. With the default handler this aborts the process instead of returningEBADF.Reject an invalid native handle before resizing and use the existing thread-local CRT suppression around
_chsize_s, preserving the caller's handler. Microsoft documents the invalid-descriptor callback that requires this handling. The regression checks both guest APIs with negative, closed and out-of-range descriptors at zero and nonzero lengths, checks handler restoration, and verifies that the real file is intact. The existing shrinking, extension and permission cases still run.Tested
I tested on Windows 11 Pro, MinGW-w64 GCC 15.2.0 (WinLibs), Release/Ninja, with
BUILD_TESTING=ON, outside the sandbox for the native filesystem cases.maind9bfa0f3a, the new regression reports 12 CRT parameter-handler invocations and fails.guest_truncate,guest_filesystem,guest_aio_bad_descriptorsandguest_duppass (4/4, 0.26 s).git diff --checkpass.ftruncatewrapper does not implement this Windows native-handle fix. The focused repository overlap check is clean.Linux/macOS and a retail title were not run; production changes are inside the existing Windows branch.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in technical debt.mdfiles or images added to the repository