Skip to content

fix: preserve daemon lifetime lock on same-process checks - #31

Merged
ngallodev merged 7 commits into
mainfrom
fix/upstream-2207-lifetime-20261102
Nov 4, 2026
Merged

ngallodev merged 7 commits into
mainfrom
fix/upstream-2207-lifetime-20261102

Conversation

@ngallodev

@ngallodev ngallodev commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Draft pending concurrency review and Jenkins qualification. POSIX record locks are released when this process closes any descriptor for the lock inode. A same-process lifetime probe or repeat acquisition used to open and close a second descriptor, potentially dropping the existing reservation. This applies upstream DeusData#2207, merge c80a2569995c44d7ad8522ea97e5944c4b5265be, to fork base 27b731cec45e2353303738ac6d8e77acbef42b7c; original fix 96e44e2a87492e4e2ac66ad5c39b6a889192f995 has the same stable patch ID as the upstream first-parent diff. Merge d48aa2de47bef6b5aa04a25373c778cb72b31cc1 preserves the upstream feature ancestry: its parents are fork fix 712a032c32e68e233871065152535abd4aa1a5bf and upstream feature tip 8bd9d37b156641ecf1c82b16b0ec0a8246e8c201, bringing upstream commits 3aec07ea3705700a1eba71321f1eb76c435a4d1d and 8bd9d37b156641ecf1c82b16b0ec0a8246e8c201 into ancestry. The merge tree is byte-identical to 712a032c32e68e233871065152535abd4aa1a5bf; relative to current upstream it reduces the upstream-only count from 926 to 924. The later upstream PR merge c80a2569995c44d7ad8522ea97e5944c4b5265be carries 888 additional upstream commits and remains for the checkpoint sequence. No dependency on unmerged PRs.

The existing-claim paths return before opening a second descriptor; two upstream regressions check that a child cannot acquire the lock after repeated probes or a repeat acquisition. Linux scripts/test.sh --suites daemon_ipc: 57 passed under ASan/UBSan, rerun after commit. Actions policy checker passed; Jenkins remains the sole automatic CI authority. No Jenkins result at this SHA or native Windows/macOS qualification is claimed. No schema or index migration is introduced.

Open correctness question: the process registry check and the later probe open/close are not guarded as one operation; a concurrent acquisition between them may still allow the close to release the new lock. Verify or eliminate this interleaving before review-ready. The originating Agent Runs were orphaned before completion and have not been evaluated or accepted; the parent inspected the patch and ran the suite. No MCP functionality is introduced.

2026-11-02 synchronization follow-up

Commit 712a032c32e68e233871065152535abd4aa1a5bf serializes process-local lifetime-lock probe/acquire/release. The earlier open correctness question is addressed in code but not yet independently validated. No tests or Jenkins result are claimed at this new head. Required: concurrent interleaving regression, fork/mutex safety review, Linux daemon_ipc sanitizer rerun and Jenkins exact-head gate. Remains draft.

Jenkins build #2 passed 57 daemon IPC tests and production build at 712a032c32e68e233871065152535abd4aa1a5bf. The new merge d48aa2de47bef6b5aa04a25373c778cb72b31cc1 has an identical tree but has not been independently tested at that SHA. Required deterministic race regression and fork review remain outstanding.

AmirF194 and others added 3 commits September 27, 2026 01:31
posix_lifetime_lock_probe opened a throwaway fd on the lock file to
confirm an already-claimed lock, then closed it. fcntl(2) record locks
are scoped to (process, inode), so that close silently released the
real lock too, even though the reservation's own fd stayed open.

Check the in-process claim before opening anything and return early;
that branch only ever needed to trust the registry.

Signed-off-by: Amir Fathi <[email protected]>
posix_lifetime_lock_try_acquire opened a throwaway fd on the lock file
to confirm an already-claimed lock, then closed it, in both the probe
path and the try-acquire-again path. fcntl(2) record locks are scoped
to (process, inode), so that close silently released the real lock
too, even though the reservation's own fd stayed open.

Check the in-process claim before opening anything and return early in
both places; neither branch ever needed more than the registry.

Also hardens the child-process verdict in the regression test: it now
reports held only when open() succeeded and F_SETLK failed with EACCES
or EAGAIN, so a wrong path or an unrelated errno can no longer read as
a pass.

Signed-off-by: Amir Fathi <[email protected]>
Adapt upstream merge c80a256 (DeusData#2207). Concurrent probe and acquisition still require review.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 27b731c and e609b19.

Files selected for processing: 3
  • src/daemon/ipc.c
  • src/daemon/ipc_internal.h
  • tests/test_daemon_ipc.c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copy link
Copy Markdown
Owner Author

Review update (2026-11-02): commit 712a032c32e68e233871065152535abd4aa1a5bf adds a process-local mutex around lifetime reservation acquisition, probing and release to close the previously identified registry-check/open-close interleaving. This is committed but not compiled or tested at the new SHA. Required before review-ready: deterministic multithreaded probe/acquire/release regression with child-process fcntl verification; examine fork and mutex behavior, cleanup/fail-stop paths, and all other lifetime-lock descriptor open/close paths; run Linux daemon_ipc ASan/UBSan and Jenkins exact-head qualification. The original 57-test pass applies to the previous commit only. Do not merge until these gates pass.

Copy link
Copy Markdown
Owner Author

Re-review at d48aa2de47bef6b5aa04a25373c778cb72b31cc1: Jenkins build #2 is reported green for production build and 57 daemon IPC tests at prior 712a032c (PR describes identical tree). Code inspection confirms the new mutex wraps public lifetime reservation acquire/probe/release. Remaining review blocker: add a deterministic concurrent probe/acquire regression with a child fcntl lock check; verify fork behavior and mutex lifetime; consider unguarded lifetime_reservation_matches_endpoint file checks and any non-public lifetime paths. Do not represent previous 57 tests as concurrency qualification. Still draft.

Copy link
Copy Markdown
Owner Author

Implementation follow-up: committed 269ed7c24ef52e448a3af13ac6f8e82759d4c3b7, adding a POSIX concurrent probe/reacquire regression (2,000 iterations per worker), child-process fcntl verification, and post-release check. This is a stress regression with a held reservation, not a deterministic forced probe-vs-first-acquisition interleaving. No compile/test/Jenkins qualification at this commit is claimed. Remaining: deterministic interleaving test, fork/mutex audit, Linux sanitizer and Jenkins qualification.

@ngallodev
ngallodev marked this pull request as ready for review November 4, 2026 03:21
@ngallodev
ngallodev merged commit 2093ca0 into main Nov 4, 2026
1 check passed
@ngallodev
ngallodev deleted the fix/upstream-2207-lifetime-20261102 branch November 4, 2026 03:22
ngallodev added a commit that referenced this pull request Nov 4, 2026
License gate step 3/3 ran `npm ci` only when graph-ui/node_modules was
missing. Jenkins main build #32 (commit 2093ca0) reused a node_modules
tree left in the persistent workspace by build #31 (2026-10-06), which was
installed from a lockfile that predates the @types/node devDependency.
The install was skipped, `tsc -b` failed with TS2688 "Cannot find type
definition file for 'node'", and every later stage was skipped.

A stale tree is also a correctness problem for the gate itself: the npm
license check would inspect packages that are not the ones this candidate
ships.

The gate now reuses an existing tree only when `npm ls --all` confirms it
matches package.json and package-lock.json. Otherwise it runs
`npm ci --ignore-scripts`, which replaces the tree. A fresh `npm ci` of the
current lockfile passes `npm ls --all`, so a matching tree does not trigger
a reinstall on every run.

Since 9f26f16 the Jenkinsfile also cleans the workspace after each
build. This change keeps the gate correct for local runs and for any
workspace the cleanup misses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants