Running-shard detection false-negative: shard launched 'mono ServUO.exe' from the server dir is seen as 'not running' #47

Closed
opened 2026-11-26 02:42:20 -06:00 by wtclaude · 0 comments
Member

Running-shard detection is a false negative when the shard is launched mono ServUO.exe from the server directory

Severity: high — it defeats the install/update safety check that is explicitly "not overridable" because deploying under a live shard corrupts Scripts.dll and/or Saves/.

Found on: installer v0.8.1 (released Linux x86_64 binary), bundle 2026.11.26.2 (servuo-plugins v1.3.3, uo-link v2.3.0), Mono 6.8 on WSL2 Ubuntu. Code path unchanged on main: src/servuo.rs::find_running (line ~218).

Summary

find_running decides a process is the shard only if its executable path + command-line arguments, normalized, contain both the ServUO root path and the string servuo.exe. On Linux the shard's working directory is never consulted. When a shard is started the normal way — from inside the server directory, mono ServUO.exe (relative), which is what a systemd unit with WorkingDirectory=<root> / ExecStart=mono ServUO.exe produces — the root path appears only in the process's cwd, not in its exe or argv. So the match fails, find_running returns None, and install/update print Shard process not running and deploy on top of a live shard.

This is the same symptom reported separately ("installer said the server was not running when it was"). It is distinct from #45 item 5 (that detection fired but reported a thread id); here detection does not fire at all.

Reproduction (empirical, with the released v0.8.1 binary)

A ServUO-shaped tree (ServUO.exe + Scripts/ + Config/ + Server/AssemblyInfo.cs reporting 57.4). ServUO.exe is a stand-in assembly that sleeps forever — find_running only inspects a process's exe/cmd/cwd, not shard internals, so the detection path is exercised faithfully. install --verify is used (writes nothing); it resolves the root through the same open_stopped/find_running as update.

Case A — operator-style launch (FAILS)

$ cd /root/servuo-test && mono ServUO.exe &          # the normal / systemd launch
  proc exe     : /usr/bin/mono-sgen
  proc cwd     : /root/servuo-test
  proc cmdline : mono ServUO.exe

$ ./runicgateway-installer install --servuo /root/servuo-test --verify
  ServUO           /root/servuo-test  (57.4.0.0)
  Shard process    not running          <-- WRONG: the shard is running
  ... proceeds to a full overlay-sync dry run (add=45) ...
  (exit 0)

Case B — absolute-path launch (works, control)

$ mono /root/servuo-test/ServUO.exe &                # full path in argv
  proc cmdline : mono /root/servuo-test/ServUO.exe

$ ./runicgateway-installer install --servuo /root/servuo-test --verify
  error: ServUO is running from /root/servuo-test (pid ... — /usr/bin/mono-sgen).
  Stop the shard before installing. ... This is not overridable.
  (exit 1)   <-- correct

Case C — genuinely stopped (works, control)

Shard process not running, proceeds. Correct.

Detection is therefore launch-shape dependent: the same running shard is caught or missed depending only on whether the full path happens to be in argv. The dangerous shape (relative launch from the root) is the common one for a service-managed shard.

Root cause

src/servuo.rs, in find_running:

let hay = normalize_for_match(&format!("{exe} {}", args.join(" ")));
if hay.contains(&root_str) && hay.contains("servuo.exe") { ... }

hay is built from exe + cmd only. The process working directory — where the root path lives for a relative launch — is never read. sysinfo::Process exposes .cwd().

Suggested fix

Treat "this process belongs to root" as satisfied by either the path appearing in exe/argv or the process's cwd being root (or a subdirectory of it), still combined with the existing servuo.exe requirement so it does not over-match:

let cwd_in_tree = process
    .cwd()
    .map(|c| normalize_for_match(&c.to_string_lossy()))
    .map(|c| c == root_str || c.starts_with(&format!("{root_str}/")))
    .unwrap_or(false);

if (hay.contains(&root_str) || cwd_in_tree) && hay.contains("servuo.exe") { ... }

Over-match risk stays low: a process whose cwd is the ServUO root and whose command line names servuo.exe is the shard (the installer already skips its own pid). A regression test in the same style as the existing nothing_is_running_out_of_an_empty_tree — a stand-in launched relative from the root must be found — would lock this in.

Side note (corroborates #45 item 5)

In Case B the refusal reported a pid one or two higher than the real process pid (pgrep PID vs the printed pid) — the /proc scan is enumerating threads (TIDs) alongside the main thread (TGID). Same find_running/sysinfo scan; worth fixing together.


Filed from automated testing by Claude Code (Opus 4.8). Reproduction scripts available on request.

# Running-shard detection is a false negative when the shard is launched `mono ServUO.exe` from the server directory **Severity:** high — it defeats the install/update safety check that is explicitly *"not overridable"* because deploying under a live shard corrupts `Scripts.dll` and/or `Saves/`. **Found on:** installer **v0.8.1** (released Linux x86_64 binary), bundle 2026.11.26.2 (servuo-plugins v1.3.3, uo-link v2.3.0), Mono 6.8 on WSL2 Ubuntu. Code path unchanged on `main`: `src/servuo.rs::find_running` (line ~218). ## Summary `find_running` decides a process is the shard only if its **executable path + command-line arguments**, normalized, contain *both* the ServUO root path *and* the string `servuo.exe`. On Linux the shard's working directory is never consulted. When a shard is started the normal way — from inside the server directory, `mono ServUO.exe` (relative), which is what a systemd unit with `WorkingDirectory=<root>` / `ExecStart=mono ServUO.exe` produces — the root path appears **only in the process's cwd**, not in its exe or argv. So the match fails, `find_running` returns `None`, and `install`/`update` print **`Shard process not running`** and deploy on top of a live shard. This is the same symptom reported separately ("installer said the server was not running when it was"). It is distinct from #45 item 5 (that detection *fired* but reported a thread id); here detection does not fire at all. ## Reproduction (empirical, with the released v0.8.1 binary) A ServUO-shaped tree (`ServUO.exe` + `Scripts/` + `Config/` + `Server/AssemblyInfo.cs` reporting 57.4). `ServUO.exe` is a stand-in assembly that sleeps forever — `find_running` only inspects a process's exe/cmd/cwd, not shard internals, so the detection path is exercised faithfully. `install --verify` is used (writes nothing); it resolves the root through the same `open_stopped`/`find_running` as `update`. ### Case A — operator-style launch (FAILS) ``` $ cd /root/servuo-test && mono ServUO.exe & # the normal / systemd launch proc exe : /usr/bin/mono-sgen proc cwd : /root/servuo-test proc cmdline : mono ServUO.exe $ ./runicgateway-installer install --servuo /root/servuo-test --verify ServUO /root/servuo-test (57.4.0.0) Shard process not running <-- WRONG: the shard is running ... proceeds to a full overlay-sync dry run (add=45) ... (exit 0) ``` ### Case B — absolute-path launch (works, control) ``` $ mono /root/servuo-test/ServUO.exe & # full path in argv proc cmdline : mono /root/servuo-test/ServUO.exe $ ./runicgateway-installer install --servuo /root/servuo-test --verify error: ServUO is running from /root/servuo-test (pid ... — /usr/bin/mono-sgen). Stop the shard before installing. ... This is not overridable. (exit 1) <-- correct ``` ### Case C — genuinely stopped (works, control) `Shard process not running`, proceeds. Correct. Detection is therefore **launch-shape dependent**: the same running shard is caught or missed depending only on whether the full path happens to be in argv. The dangerous shape (relative launch from the root) is the common one for a service-managed shard. ## Root cause `src/servuo.rs`, in `find_running`: ```rust let hay = normalize_for_match(&format!("{exe} {}", args.join(" "))); if hay.contains(&root_str) && hay.contains("servuo.exe") { ... } ``` `hay` is built from `exe` + `cmd` only. The process working directory — where the root path lives for a relative launch — is never read. `sysinfo::Process` exposes `.cwd()`. ## Suggested fix Treat "this process belongs to `root`" as satisfied by **either** the path appearing in exe/argv **or** the process's cwd being `root` (or a subdirectory of it), still combined with the existing `servuo.exe` requirement so it does not over-match: ```rust let cwd_in_tree = process .cwd() .map(|c| normalize_for_match(&c.to_string_lossy())) .map(|c| c == root_str || c.starts_with(&format!("{root_str}/"))) .unwrap_or(false); if (hay.contains(&root_str) || cwd_in_tree) && hay.contains("servuo.exe") { ... } ``` Over-match risk stays low: a process whose cwd is the ServUO root *and* whose command line names `servuo.exe` is the shard (the installer already skips its own pid). A regression test in the same style as the existing `nothing_is_running_out_of_an_empty_tree` — a stand-in launched relative from the root must be found — would lock this in. ## Side note (corroborates #45 item 5) In Case B the refusal reported a pid one or two higher than the real process pid (`pgrep` PID vs the printed pid) — the `/proc` scan is enumerating threads (TIDs) alongside the main thread (TGID). Same `find_running`/sysinfo scan; worth fixing together. --- *Filed from automated testing by Claude Code (Opus 4.8). Reproduction scripts available on request.*
Sign in to join this conversation.
No description provided.