fix(libkernel): name the failing vnode watch in the kqueue notification error #5493

Merged
Roojool merged 2 commits from upstream-pr/5493 into main 2026-10-14 22:27:24 +00:00
Roojool commented 2026-10-13 21:03:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-13T21:03:28Z.


What

EVFILT_VNODE watch errors now name the failing watcher, the path that was passed to FindFirstChangeNotification, and GetLastError, instead of the anonymous EVFILT_VNODE: FindFirstChangeNotification failed, error=5 that the Windows CI job printed.

In the windows job of run 38451769652 (attempt 1, job 115484249079), guest_kqueue aborted with exactly that string and exit code 0xC0000409; attempt 2 of the same run passed, so the trigger is transient — which is precisely why the error needs to carry its context. This is the context #5435's review asked for: which notification handle and path was denied.

The messages now read, for example:

EVFILT_VNODE: the parent watch of "\\?\C:\...\anyps5-kqueue-denied-3\" failed, FindFirstChangeNotification error=5

WatchParent, WatchContents (entries/subdirectories) each label themselves; both WatchParent call sites (initial attach and re-registration) are labelled parent, so the message discriminates where the failure came from. Only the parent watch fails this way in practice — the watched directory itself is opened with FILE_LIST_DIRECTORY first, so a denial there surfaces earlier (modulo a rename or ACL change racing the two calls).

Behaviour is unchanged: the call still throws. FreeBSD's vfs_kqfilter errno set is {EBADF, EINVAL, ENOMEM} and consults no directory permission, so ERROR_ACCESS_DENIED has no counterpart to map to — inventing one is not grounded, and the throw stands per CONTRIBUTING.

Overlap: #5393 touches the same files with a behaviour change for a measured delete-pending re-registration path. This PR is complementary and diagnosability-only — its named-watcher message discriminates the two hypotheses on the next recurrence (which call site and path failed), which raises the information value of #5393's own validation. Happy to rebase onto #5393 if it merges first.

Tested

  • Local reproduction of the CI failure on unmodified main: deny FILE_LIST_DIRECTORY on the watched directory's parent, run guest_kqueue → the same error=5 throw → abort 0xC0000409 (receipts/G14-reproduction.txt). With this change the same run names the parent watch and the denied path before aborting.
  • New Windows-only DeniedParentWatch case in guest_kqueue: DACL-denied parent → the thrown message contains parent, error=5 and the absolute parent path (case-insensitively against the NT-normalized form); the DACL is restored before any assertion, so a failure does not strand a denied directory; afterwards the same watch is re-added and still delivers NOTE_WRITE. On unmodified main this test fails with the vnode watch error lacks "parent" (receipts/G14-base-fail-windows.txt).
  • Windows (WinLibs GCC 15.2.0): guest_kqueue 5/5 plus 10 file/directory/descriptor neighbours 11/11.
  • WSL2 Linux (g++ 15.2.0): guest_kqueue + 11 neighbours 12/12 (the changed code is inside #ifdef _WIN32; this proves build and no regression).
  • python tools/check_conventions.py --base upstream/main passes.

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; silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4849446169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493). Originally posted by [Roojool](https://github.com/Roojool) on 2026-10-13T21:03:28Z. --- ### What `EVFILT_VNODE` watch errors now name the failing watcher, the path that was passed to `FindFirstChangeNotification`, and `GetLastError`, instead of the anonymous `EVFILT_VNODE: FindFirstChangeNotification failed, error=5` that the Windows CI job printed. In the windows job of run [38451769652](https://github.com/boykopovar/AnyPS5/actions/runs/38451769652) (attempt 1, job 115484249079), `guest_kqueue` aborted with exactly that string and exit code `0xC0000409`; attempt 2 of the same run passed, so the trigger is transient — which is precisely why the error needs to carry its context. This is the context #5435's review asked for: which notification handle and path was denied. The messages now read, for example: ``` EVFILT_VNODE: the parent watch of "\\?\C:\...\anyps5-kqueue-denied-3\" failed, FindFirstChangeNotification error=5 ``` `WatchParent`, `WatchContents` (entries/subdirectories) each label themselves; both `WatchParent` call sites (initial attach and re-registration) are labelled `parent`, so the message discriminates where the failure came from. Only the parent watch fails this way in practice — the watched directory itself is opened with `FILE_LIST_DIRECTORY` first, so a denial there surfaces earlier (modulo a rename or ACL change racing the two calls). Behaviour is unchanged: the call still throws. FreeBSD's `vfs_kqfilter` errno set is `{EBADF, EINVAL, ENOMEM}` and consults no directory permission, so `ERROR_ACCESS_DENIED` has no counterpart to map to — inventing one is not grounded, and the throw stands per CONTRIBUTING. Overlap: #5393 touches the same files with a behaviour change for a measured delete-pending re-registration path. This PR is complementary and diagnosability-only — its named-watcher message discriminates the two hypotheses on the next recurrence (which call site and path failed), which raises the information value of #5393's own validation. Happy to rebase onto #5393 if it merges first. ### Tested - Local reproduction of the CI failure on unmodified `main`: deny `FILE_LIST_DIRECTORY` on the watched directory's parent, run `guest_kqueue` → the same `error=5` throw → abort `0xC0000409` (receipts/G14-reproduction.txt). With this change the same run names the `parent` watch and the denied path before aborting. - New Windows-only `DeniedParentWatch` case in `guest_kqueue`: DACL-denied parent → the thrown message contains `parent`, `error=5` and the absolute parent path (case-insensitively against the NT-normalized form); the DACL is restored before any assertion, so a failure does not strand a denied directory; afterwards the same watch is re-added and still delivers `NOTE_WRITE`. On unmodified `main` this test fails with `the vnode watch error lacks "parent"` (receipts/G14-base-fail-windows.txt). - Windows (WinLibs GCC 15.2.0): `guest_kqueue` 5/5 plus 10 file/directory/descriptor neighbours 11/11. - WSL2 Linux (g++ 15.2.0): `guest_kqueue` + 11 neighbours 12/12 (the changed code is inside `#ifdef _WIN32`; this proves build and no regression). - `python tools/check_conventions.py --base upstream/main` passes. ### Checklist - [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 - [x] Unimplemented paths throw; silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-13 21:03:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-13T21:03:35Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5509928426 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#pullrequestreview-5509928426). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-13T21:03:35Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MarcZX10 commented 2026-10-13 22:07:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T22:07:25Z.

Review: COMMENTED


I checked this against the intermittent #5435 failure. The error now distinguishes parent, entries and subdirectories, and includes the path passed to the Windows API plus GetLastError; the denied-parent test restores the DACL before its assertions and verifies the watch works afterward. Keeping the unsupported host-permission case as a throw is consistent with the lack of a grounded FreeBSD errno mapping. Applicable CI checks pass; the full path-filtered build jobs are skipped, with the Windows run documented in the PR. No further issue from me.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5510587096 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#pullrequestreview-5510587096). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T22:07:25Z. **Review:** COMMENTED --- I checked this against the intermittent #5435 failure. The error now distinguishes `parent`, `entries` and `subdirectories`, and includes the path passed to the Windows API plus `GetLastError`; the denied-parent test restores the DACL before its assertions and verifies the watch works afterward. Keeping the unsupported host-permission case as a throw is consistent with the lack of a grounded FreeBSD errno mapping. Applicable CI checks pass; the full path-filtered build jobs are skipped, with the Windows run documented in the PR. No further issue from me.
Roojool commented 2026-10-14 05:05:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-14T05:05:49Z.


#5435 was closed with the fix in #5393 (merged). This PR keeps its scope — diagnosability only — and is now rebased on top of #5393, so both changes coexist: the watch no longer fails for the delete-pending path #5393 fixed, and if the transient Windows failure recurs, the error now names which of the parent/entries/subdirectories watches, on which path, was denied — the log-line context the close note asks for. Both test cases (delete-watched-file and denied-parent-watch) are kept.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161334849 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#issuecomment-6161334849). Originally posted by [Roojool](https://github.com/Roojool) on 2026-10-14T05:05:49Z. --- #5435 was closed with the fix in #5393 (merged). This PR keeps its scope — diagnosability only — and is now rebased on top of #5393, so both changes coexist: the watch no longer fails for the delete-pending path #5393 fixed, and if the transient Windows failure recurs, the error now names which of the parent/entries/subdirectories watches, on which path, was denied — the log-line context the close note asks for. Both test cases (delete-watched-file and denied-parent-watch) are kept.
copilot-pull-request-reviewer[bot] commented 2026-10-14 05:05:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-14T05:05:55Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5513309959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#pullrequestreview-5513309959). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-14T05:05:55Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
github-actions[bot] commented 2026-10-14 13:47:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T13:47:50Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#5847 docs/dev/debt/libkernel.md L110-111
#5973 docs/dev/debt/libkernel.md L110-111
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169877198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#issuecomment-6169877198). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T13:47:50Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5847 | `docs/dev/debt/libkernel.md` [L110-111](https://github.com/boykopovar/AnyPS5/blob/80ccb9fb1eccb190f689aeef0907f25848837890/docs/dev/debt/libkernel.md#L110-L111) | | | | #5973 | `docs/dev/debt/libkernel.md` [L110-111](https://github.com/boykopovar/AnyPS5/blob/80ccb9fb1eccb190f689aeef0907f25848837890/docs/dev/debt/libkernel.md#L110-L111) | | |
adriadam10 commented 2026-10-14 20:48:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T20:48:56Z.


Checked the diff, rebased onto current main and ran build + guest_kqueue on Linux (the changed code is _WIN32-only; Windows is covered by the full Build before merge).

Added two small commits' worth of fixes on top of your branch:

  • docs/dev/debt/libkernel.md: the sem_timedwait entry had been joined onto the end of the EVFILT_VNODE line (...neither confirmed on a title- [sem_timedwait]...); split back into its own bullet.
  • core/libs/tests/GuestKqueue.cpp: include <algorithm> and <cctype> for std::transform / std::tolower.

Merging once the Windows build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178133834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#issuecomment-6178133834). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T20:48:56Z. --- Checked the diff, rebased onto current main and ran build + `guest_kqueue` on Linux (the changed code is `_WIN32`-only; Windows is covered by the full Build before merge). Added two small commits' worth of fixes on top of your branch: - `docs/dev/debt/libkernel.md`: the `sem_timedwait` entry had been joined onto the end of the EVFILT_VNODE line (`...neither confirmed on a title- [sem_timedwait]...`); split back into its own bullet. - `core/libs/tests/GuestKqueue.cpp`: include `<algorithm>` and `<cctype>` for `std::transform` / `std::tolower`. Merging once the Windows build is green.
copilot-pull-request-reviewer[bot] commented 2026-10-14 20:49:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-14T20:49:01Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5524470339 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#pullrequestreview-5524470339). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-14T20:49:01Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
frankea commented 2026-10-15 04:04:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T04:04:03Z.


The new DeniedParentWatch case aborts deterministically on a Windows box where the test process runs elevated. main a077a88df (also with #6060 or #6168 merged, same result), Windows 11 10.0.26200, MinGW-w64 GCC 15.2.0 r7, Release; 4 of 4 runs:

the vnode watch error lacks "parent":
FATAL: abort() (SIGABRT) on thread 20308

The quoted error text is empty, so the watch on the DACL-denied parent succeeded and nothing was thrown. The process is an OpenSSH session of a local administrator: whoami /groups shows BUILTIN\Administrators enabled and Mandatory Label\High Mandatory Level, and whoami /priv shows SeBackupPrivilege, SeRestorePrivilege, SeSecurityPrivilege and SeTakeOwnershipPrivilege enabled. With backup privilege held, FILE_LIST_DIRECTORY is granted regardless of the deny ACE, so FindFirstChangeNotification on the parent does not fail. guest_kqueue passed 5 of 5 on this box at main fa539dd9b, before this change.

A skip (exit 77) when the deny cannot take effect, for example when the process holds SeBackupPrivilege or the parent can still be listed after the DACL is applied, would keep the case meaningful on unprivileged runners without failing elevated ones.

Tested with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6184129796 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5493#issuecomment-6184129796). Originally posted by [frankea](https://github.com/frankea) on 2026-10-15T04:04:03Z. --- The new `DeniedParentWatch` case aborts deterministically on a Windows box where the test process runs elevated. `main` `a077a88df` (also with #6060 or #6168 merged, same result), Windows 11 10.0.26200, MinGW-w64 GCC 15.2.0 r7, Release; 4 of 4 runs: ``` the vnode watch error lacks "parent": FATAL: abort() (SIGABRT) on thread 20308 ``` The quoted error text is empty, so the watch on the DACL-denied parent succeeded and nothing was thrown. The process is an OpenSSH session of a local administrator: `whoami /groups` shows `BUILTIN\Administrators` enabled and `Mandatory Label\High Mandatory Level`, and `whoami /priv` shows `SeBackupPrivilege`, `SeRestorePrivilege`, `SeSecurityPrivilege` and `SeTakeOwnershipPrivilege` enabled. With backup privilege held, `FILE_LIST_DIRECTORY` is granted regardless of the deny ACE, so `FindFirstChangeNotification` on the parent does not fail. `guest_kqueue` passed 5 of 5 on this box at `main` `fa539dd9b`, before this change. A skip (exit 77) when the deny cannot take effect, for example when the process holds `SeBackupPrivilege` or the parent can still be listed after the DACL is applied, would keep the case meaningful on unprivileged runners without failing elevated ones. Tested with AI assistance (Claude Code).
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!5493
No description provided.