Repository navigation
Conversation
Messages were not bounds-checked, so short or garbage input read past the buffer, and a null checker thread could be joined. A forced Desktop shutdown showed a misleading crash dialog, and exit messages went to one global pipe that a leftover obs64 from another session could receive. Messages are now validated and dropped when invalid. terminateCrashHandler is replaced by markShutdownIntent, and obs64 reports output state so the handler can skip waits when nothing is live. Exit messages use a per-session pipe, falling back to the legacy pipe only for obs64 builds that never report output state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved exit-handling defects can terminate live outputs before user confirmation, target a leftover obs64 instance through a shared pipe, and suppress the post-confirmation retry after failed delivery.
4 open issues
What changed in this PR
This PR hardens crash-handler messaging and adds output-aware shutdown handling for Desktop and obs64, alongside the companion obs-studio-node orphan-policy changes.
Changes:
- Adds bounds checks, malformed-message logging, and null-safe checker-thread joins.
- Introduces output-state and shutdown-intent messages to support early exit and suppress intentional-shutdown dialogs.
- Derives Windows exit-pipe names from the session pipe, with conditional legacy fallback.
| File | Description |
|---|---|
crash-handler-process/socket.hpp |
Adds a legacy exit-write interface. |
crash-handler-process/process-manager.hpp |
Declares shutdown-intent and output-state tracking. |
crash-handler-process/process-manager.cpp |
Handles new messages and output-aware exit decisions. |
crash-handler-process/platforms/socket-win.hpp |
Declares legacy pipe storage and shared write helper. |
crash-handler-process/platforms/socket-win.cpp |
Derives exit-pipe names and returns actual received bytes. |
crash-handler-process/platforms/process-win.cpp |
Guards checker-thread joins against null pointers. |
crash-handler-process/message.hpp |
Defines new actions and message-validation interfaces. |
crash-handler-process/message.cpp |
Adds bounds checks for primitive and string reads. |
crash-handler-module/main.js |
Replaces terminateCrashHandler with markShutdownIntent. |
Review effort: Balanced
…shutdown intent synchronous An early exit now needs every critical process to have reported inactive, and is only counted as sent when a write succeeded, so the post-dialog send still runs after a failure. markShutdownIntent writes the pipe synchronously because Desktop calls app.exit right after it and an async connect never delivered the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The macOS transport can still send exit commands to another session’s shared pipe, while shutdown-intent writes can be lost or remain unprocessed and trigger a false crash dialog.
3 open issues
4 resolved since last review
Review effort: Balanced
| if (this->socket->write(true, buffer) > 0) | ||
| return true; |
There was a problem hiding this comment.
Declining for now. The concern is real, but obs64 on macOS (obs-studio-node#1852) only listens on the single legacy exit FIFO, so a per-session mac path would drop the exit message. Tracked in #140 (obs-studio-node listener first, then crash-handler).
| const attempts = 5; | ||
| for (let i = 0; i < attempts; i++) { | ||
| try { | ||
| const fd = fs.openSync(socket_name, 'r+'); |
There was a problem hiding this comment.
Fixed in 4467f1b. On non-Windows the FIFO is now opened O_WRONLY|O_NONBLOCK, so a missing reader gives ENXIO and retries; 'r+' stays on Windows. Retry sleep is 25 ms to cover the poll gap.
| } finally { | ||
| fs.closeSync(fd); | ||
| } | ||
| return true; |
There was a problem hiding this comment.
Accepted as best-effort, no code change. The window is the final poll of at most 50 ms around Desktop exiting, and the worst case is the existing crash dialog. Closing it needs an ack, which is a protocol change in both repos.
With 'r+' the sender supplies its own reader, so a write could succeed while the crash handler had the FIFO closed between polls and the message was lost. ENXIO now triggers the retry; the sleep covers the ~50 ms poll gap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| try { | ||
| // Write-only + nonblocking on POSIX so a missing FIFO reader fails with ENXIO and retries. | ||
| const flags = process.platform === 'win32' ? 'r+' : fs.constants.O_WRONLY | fs.constants.O_NONBLOCK; | ||
| const fd = fs.openSync(socket_name, flags); |


Problem: Short or garbage messages were read past the buffer, a null
checkerthread could be joined, a forced Desktop shutdown showed a misleading crash dialog, and exit messages on one global pipe could reach a leftover obs64 from another session.Change:
Messageis bounds-checked; invalid messages are dropped and logged. New actions OUTPUT_STATE=6 (obs64) and SHUTDOWN_INTENT=7 (Desktop, viamarkShutdownIntent(pid), replacingterminateCrashHandler). Exit messages go to a per-session pipe, with legacy-pipe fallback for obs64 that never sent OUTPUT_STATE.Effect: After a shutdown intent, no crash dialog. If nothing is live, obs64 gets the exit message immediately; the restart prompt is unchanged.
Ships with the obs-studio-node orphan-policy PR; Desktop calls
markShutdownIntentin a separate PR.Tests
crash-handler-process.exebuilds (RelWithDebInfo); clang-format 13.0.1 and 18.1.3 cleanNot verified:
.nodemodule build, macOS, Application Verifier. Known gap: if obs64 exits while the restart prompt is up, it stays until clicked.🤖 Generated with Claude Code