Skip to content

Restore the stale-server report and orphan policy lost from staging - #1852

Merged
summeroff merged 5 commits into
stagingfrom
restore-stale-server-and-orphan-policy
Nov 17, 2026
Merged

summeroff merged 5 commits into
stagingfrom
restore-stale-server-and-orphan-policy

Conversation

@summeroff

Copy link
Copy Markdown
Contributor

Problem: #1830 and #1829 were merged into their parent branches after those parents (#1820, #1821) had already been squash-merged, so neither change reached staging.

Change: Applies both squash commits onto staging unchanged:

#1829 is safe before streamlabs/crash-handler#139 ships: the current crash-handler ignores OUTPUT_STATE, and obs64 still listens on the legacy exit pipe.

Tests

  • Both commits apply to staging without conflicts
  • clang-format 18.1.3: 9 changed C++ files clean
  • tsc -p js: generated files in sync
  • Build and unit tests: CI

🤖 Generated with Claude Code

…ed (#1830)

* Report a previous server that can't be stopped because it runs elevated

A non-elevated Desktop cannot open, and so cannot kill, an elevated leftover obs64. That process holds CEF's cache lock, so browser sources are disabled for the session with no explanation. Record its PID and expose it via IPC.getUnkillableStaleServer() so the app can tell the user.
* Let an orphaned obs64 decide whether to wait for the user

obs64 waited indefinitely on crash-handler's ack over one global exit pipe, even with nothing live, and a leftover obs64 holding that pipe broke the next session. It now reports live outputs to crash-handler, uses a per-session exit pipe, and stops waiting when idle or when crash-handler dies.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical defects can omit live legacy outputs from activity tracking, dereference freed output wrappers after reinitialization, and block shutdown indefinitely on synchronous pipe writes.

3 open issues
What changed in this PR

Restores stale-server reporting and orphan shutdown handling that missed staging, extending the existing protections against leftover obs64 processes holding browser-cache locks.

Changes:

  • Adds IPC.getUnkillableStaleServer() and TypeScript declarations so Desktop can report a previous server it cannot terminate.
  • Adds Windows orphan shutdown decisions based on output activity, exit acknowledgement, and crash-handler liveness, with session-specific and legacy exit pipes.
  • Adds orphan-policy unit tests and build registration.
File Description
obs-studio-server/​tests/​test-orphan-policy.cpp Tests idle, acknowledgement, and crash-handler grace-period decisions.
obs-studio-server/​source/​osn-output.hpp Declares atomic output-activity tracking.
obs-studio-server/​source/​osn-output.cpp Updates activity tracking from output lifecycle signals.
obs-studio-server/​source/​orphan-policy.hpp Defines the orphan shutdown decision policy.
obs-studio-server/​source/​nodeobs_api.h Declares output-state polling and publication methods.
obs-studio-server/​source/​nodeobs_api.cpp Implements output reporting, handler tracking, exit pipes, and orphan waits.
obs-studio-server/​source/​main.cpp Publishes output state from the Windows main loop.
obs-studio-server/​CMakeLists.txt Registers the orphan-policy header and tests.
obs-studio-client/​source/​controller.hpp Declares stale-server PID storage and access.
obs-studio-client/​source/​controller.cpp Detects unkillable server processes and exposes the IPC getter.
js/​module.ts Documents and declares the new IPC method.
js/​module.d.ts Adds the method to generated TypeScript declarations.

Review effort: Balanced

summeroff and others added 2 commits November 16, 2026 15:27
Terminate handlers are per-thread on MSVC and the SIGABRT handler is one-shot, so after obs_startup a worker-thread abort/terminate ran HandleCrash once, then its final abort() hit SIG_DFL and fast-failed with no crash report. The stack was also logged only after the log was captured.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
destroyOBS_API deleted streaming/file-output wrappers but left their registry entries, so a re-init could poll freed pointers. AnyLiveOutput also ignored raw outputs started through the legacy OBS_service API, reporting no live output while one was running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active issues include a critical use-after-free risk in legacy output polling and missing legacy replay-buffer activity tracking that can cause shutdown without acknowledgement.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Track legacy replay-buffer activity in output state

obs-studio-server/​source/​nodeobs_api.cpp:1704

A legacy replay-buffer-only session still publishes OUTPUT_STATE=false, so losing Desktop shuts it down without waiting for acknowledgement. The independently owned replayBufferOutput is absent from both wrapper registries and these checks (nodeobs_service.cpp:2009,2101–2104). Include legacy replay-buffer activity using lifetime-safe tracking alongside the streaming and recording states.

2 resolved since last review

Review effort: Balanced

releaseStreamingOutput frees and nulls those outputs on a worker thread with no lock shared with the main-loop poll, so reading them could touch a freed output. Desktop does not stream or record through OBS_service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The SIGABRT fallback can deadlock by re-entering the logger while its mutex is held, preventing both crash reporting and process termination.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

High severity Avoid re-entering the logger from the SIGABRT fallback

obs-studio-server/​source/​util-crashmanager.cpp:570

If SIGABRT occurs while the logger holds logMutex (nodeobs_api.cpp:552–587), both branches re-enter blog() and can deadlock on the same nonrecursive mutex. This prevents the process from reaching Crashpad or _exit, leaving it hung without a crash report. Forward directly to osn_crashpad_bridge_abort() from this fallback, without allocating or acquiring application locks; collect richer diagnostics outside the SIGABRT handler.

Medium severity Restrict stale-server checks to the validated prior server

obs-studio-client/​source/​controller.cpp:254

The image-path match does not establish that a process is the previous server: CEF subprocesses use the same executable (main.cpp:188–190), and the scan also includes servers from other sessions. If one of these processes denies the requested access, getUnkillableStaleServer() can report its PID even when the previous server is gone. Check a validated previous-server identity, or both server role and stale-session ownership, before recording the PID.

2 resolved since last review

Review effort: Balanced

@summeroff
summeroff merged commit c624f16 into staging Nov 17, 2026
29 of 31 checks passed
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