Skip to content

treat EPERM as alive in the pending-launch liveness probe - #18574

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/isprocessrunning-eperm
Aug 18, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/isprocessrunning-eperm

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Follow-up to #18573, which added a liveness guard in ServerSessionManager::removePendingLaunch: a request error no longer erases the pending-launch record while the launched session process is still alive. The guard probes liveness with core::system::isProcessRunning, which returned kill(pid, 0) == 0 -- but on a root-launched multi-user server, rserver's request-handling threads run privilege-dropped (temporarilyDropPrivileges leaves ruid 0 and euid server-user, and the euid transition clears the effective capability set, so no CAP_KILL), and kill(pid, 0) fails with EPERM for every live rsession owned by another user. The guard read that as "not running", erased the record on the error path exactly as before #18573, and the #18572 double-launch/orphan race remained reproducible in precisely the deployment class it targets. Dev and e2e servers were unaffected (rserver and its sessions share a uid there), which is why #18573's verification passed.

isProcessRunning now counts EPERM as proof the process exists -- only ESRCH means it is gone. That is the established polarity for cross-user liveness probes (psutil's pid_exists: "EPERM clearly means there's a process to deny access to"; moby's process.Alive on macOS is err == nil || errors.Is(err, unix.EPERM)), and the #18573 guard is the function's only caller.

Verification:

  • New tests: PosixTests.IsProcessRunningDetectsLiveAndDeadProcesses (core) and SessionManagerTest.RequestErrorKeepsPendingLaunchOfOtherUserProcess (rserver). Both probe pid 1, which always exists and is owned by root, so an unprivileged test run exercises the EPERM path (and a privileged one still passes); the new rserver test fails against the previous probe.
  • rstudio-tests --scope core: all pass. --scope rserver: all SessionManagerTest pass; the SqliteDBActiveSessionStorageTest failures are environmental on this machine and identical on main's build (same as noted on fix rserver double session launch that leaks an orphaned rsession #18573).

No NEWS entry: this completes the unreleased #18573 fix, whose #18572 entry already covers the user-facing behavior.

Fixes #18572.

kill(pid, 0) fails with EPERM when the probed process exists but is
owned by another user -- exactly what rserver's privilege-dropped
request threads see when probing a live rsession on a root-launched
multi-user server. The liveness guard from #18573 read that as "not
running" and erased the pending-launch record on request errors, so
the #18572 double-launch stayed reproducible in precisely the
deployment class it targets (dev and e2e servers share a uid with
their sessions and were unaffected). Only ESRCH proves absence; count
EPERM as alive.

Addresses #18572.
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
2386 1 152 2
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
❌ desktop-linux 592 1 31 0
✅ desktop-macos 598 0 26 1
✅ desktop-windows 599 0 31 0
✅ server-linux 569 0 44 1
✅ setup 26 0 10 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit a64e60d0d79dabfef9a01bd28d355df09c2751bf - Run #628

@kevinushey
kevinushey merged commit b0ae9c9 into main Aug 18, 2026
28 of 29 checks passed
@kevinushey
kevinushey deleted the bugfix/isprocessrunning-eperm branch August 18, 2026 18:01
@gtritchie gtritchie mentioned this pull request Aug 31, 2026
3 of 4 tasks

This branch was previously deployed

1 inactive deployment
e2e-playwright — a64e60d0 Deployed Aug 16, 2026 by kevinushey via windows / e2e-desktop-windows (2) #628
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.

rserver can double-launch a session during restart, leaking an orphaned rsession

1 participant