fix(libkernel): fail futimes on a kqueue with EINVAL, as FreeBSD 11.4 does #24483

Merged
brajankw merged 1 commit from upstream-pr/24483 into main 2026-11-21 13:12:57 +00:00
brajankw commented 2026-11-20 17:23:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by brajankw on 2026-11-20T17:23:48Z.


What

A kqueue descriptor is a host null device here, so futimes and sceKernelFutimes tried to set the null device's times and failed with the host's error. FreeBSD 11.4's kern_futimes takes the vnode through getvnode, which fails with EINVAL for a kqueue, after getutimes has copied and checked the times.

  • The check sits just before the host call, after the times are checked, rather than beside the socket check, so that it does not touch the line my open ksem PR changes; the order is the same as FreeBSD's.
  • Tests: KqueueDescriptorOperations in GuestKqueue.cpp, through both exports.
  • Debt: no fragment.

Tested

Linux (Debian 13, GCC 14.2.0, Release). Head a8b5662f63, the single commit on main c8f72e905c.

  • Negative control: with only the test change, on main 84e16538d4, guest_kqueue aborts at the new futimes check.
  • On a8b5662f63, ctest over guest_kqueue, guest_equeue_events and guest_filesystem: all pass.
  • Full ctest (6393 tests, -j 12) on this branch and my other eleven branches of this round, merged onto main 84e16538d4: 6378 passed. The 15 failures also fail on main in this environment:
    • nine need a .git directory, network access or a passwd entry for the user: conventions_git_errors, test_script_registration, web_library_assets, title_run, title_run_identity, guest_kernel_sys_login, guest_net_ctl, guest_getlogin and guest_getlogin_no_session;
    • five agc_driver GPU cases fail the same way on main: prepared_shaders with its indirect, uncached and debug forms, and storage_file_write;
    • agc_driver_image_table_packed_guards is unstable on main as well (2 of 10 runs passed on its own on main 3f4693be43).
  • python3 tools/check_conventions.py --base origin/main: passed.
  • python3 tools/pr_overlap.py --branch fix/libkernel-kqueue-futimes-einval: could not compare #6936, #7121, #7447, #9293, #9297, #9302, #12682, #12688, #12700, #12965 and #15037, which conflict with main in Stdio.cpp; none of their diffs touches sceKernelFutimes.
  • Not tested on Windows or macOS. No title.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5417499095 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24483). Originally posted by [brajankw](https://github.com/brajankw) on 2026-11-20T17:23:48Z. --- ### What A kqueue descriptor is a host null device here, so `futimes` and `sceKernelFutimes` tried to set the null device's times and failed with the host's error. FreeBSD 11.4's `kern_futimes` takes the vnode through [`getvnode`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/vfs_syscalls.c#L3850-L3877), which fails with `EINVAL` for a kqueue, after `getutimes` has copied and checked the times. - The check sits just before the host call, after the times are checked, rather than beside the socket check, so that it does not touch the line my open ksem PR changes; the order is the same as FreeBSD's. - Tests: `KqueueDescriptorOperations` in `GuestKqueue.cpp`, through both exports. - Debt: no fragment. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux (Debian 13, GCC 14.2.0, Release). Head `a8b5662f63`, the single commit on `main` `c8f72e905c`. - Negative control: with only the test change, on `main` `84e16538d4`, `guest_kqueue` aborts at the new `futimes` check. - On `a8b5662f63`, `ctest` over `guest_kqueue`, `guest_equeue_events` and `guest_filesystem`: all pass. - Full `ctest` (6393 tests, `-j 12`) on this branch and my other eleven branches of this round, merged onto `main` `84e16538d4`: 6378 passed. The 15 failures also fail on `main` in this environment: - nine need a `.git` directory, network access or a passwd entry for the user: `conventions_git_errors`, `test_script_registration`, `web_library_assets`, `title_run`, `title_run_identity`, `guest_kernel_sys_login`, `guest_net_ctl`, `guest_getlogin` and `guest_getlogin_no_session`; - five `agc_driver` GPU cases fail the same way on `main`: `prepared_shaders` with its `indirect`, `uncached` and `debug` forms, and `storage_file_write`; - `agc_driver_image_table_packed_guards` is unstable on `main` as well (2 of 10 runs passed on its own on `main` `3f4693be43`). - `python3 tools/check_conventions.py --base origin/main`: passed. - `python3 tools/pr_overlap.py --branch fix/libkernel-kqueue-futimes-einval`: could not compare #6936, #7121, #7447, #9293, #9297, #9302, #12682, #12688, #12700, #12965 and #15037, which conflict with `main` in `Stdio.cpp`; none of their diffs touches `sceKernelFutimes`. - Not tested on Windows or macOS. No title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-21 05:39:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:39:53Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected change blocks merging; the focused change and tests match the stated behavior.

What I ran

Reviewed head a8b5662f6397406d552023ad31aae7ea6aedd998. No commands or tests were run; repository files were read with repo_read.py.

Results

Check Result Note
Diff and changed code passed Both changed files read
Targeted callers and tests passed Existing timestamp behavior inspected
Tests in this review not run Author reports focused tests passed

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not run tests, inspect CI output, or verify behavior on Windows, macOS, or a console. The author-reported test results were not independently verified. Read description.md, commits.md, manifest.json, diff.patch, Stdio.cpp, GuestKqueue.cpp, Kqueue.cpp, and GuestFileTimestamps.cpp. files.json was not available as a review document; the file listing confirms both changed files were included, and both were read. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003214381 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24483#pullrequestreview-6003214381). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T05:39:53Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected change blocks merging; the focused change and tests match the stated behavior. ## What I ran Reviewed head `a8b5662f6397406d552023ad31aae7ea6aedd998`. No commands or tests were run; repository files were read with `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Both changed files read | | Targeted callers and tests | passed | Existing timestamp behavior inspected | | Tests in this review | not run | Author reports focused tests passed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Did not run tests, inspect CI output, or verify behavior on Windows, macOS, or a console. The author-reported test results were not independently verified. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `Stdio.cpp`, `GuestKqueue.cpp`, `Kqueue.cpp`, and `GuestFileTimestamps.cpp`. `files.json` was not available as a review document; the file listing confirms both changed files were included, and both were read. No changed files were excluded. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
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!24483
No description provided.