🛡️ Sentinel: [MEDIUM] Fix Process Deadlocks#80
Conversation
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
📝 WalkthroughWalkthroughThe change reorders subprocess output handling so pipe data is read via readDataToEndOfFile() before calling waitUntilExit(), applied in AutomationExecutor's runProcess and childPIDs(of:), and UniversalControlMouseRelay's tailscalePeerHosts(). A sentinel.md entry documents the underlying deadlock pattern. ChangesPipe read/wait ordering fix
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Process
participant Pipe
Caller->>Process: launch()
Caller->>Pipe: readDataToEndOfFile()
Pipe-->>Caller: output data
Caller->>Process: waitUntilExit()
Process-->>Caller: terminationStatus
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
XboxControllerMapper/XboxControllerMapper/Services/Input/UniversalControlMouseRelay.swift (1)
1400-1410: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winUnread stderr pipe can still deadlock.
process.standardError = Pipe()creates a second pipe that is never drained. Iftailscale status --jsonwrites more than ~64KB to stderr, the child blocks on the stderr pipe write while the parent blocks onreadDataToEndOfFile()for stdout — the same deadlock this PR set out to fix.Redirect stderr to
nullDeviceinstead, matching the pattern inchildPIDs(of:)inAutomationExecutor.swift(line 732).🔧 Proposed fix
- process.standardError = Pipe() + process.standardError = FileHandle.nullDevice🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@XboxControllerMapper/XboxControllerMapper/Services/Input/UniversalControlMouseRelay.swift` around lines 1400 - 1410, The `tailscale status --json` launch in `UniversalControlMouseRelay` still creates an unread `standardError` pipe, which can deadlock the process when stderr fills up. Update the `process.run()` setup to redirect `standardError` to `FileHandle.nullDevice` instead of `Pipe()`, following the same pattern used by `childPIDs(of:)` in `AutomationExecutor`, while leaving the stdout read path unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@XboxControllerMapper/XboxControllerMapper/Services/Input/UniversalControlMouseRelay.swift`:
- Around line 1400-1410: The `tailscale status --json` launch in
`UniversalControlMouseRelay` still creates an unread `standardError` pipe, which
can deadlock the process when stderr fills up. Update the `process.run()` setup
to redirect `standardError` to `FileHandle.nullDevice` instead of `Pipe()`,
following the same pattern used by `childPIDs(of:)` in `AutomationExecutor`,
while leaving the stdout read path unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 64ae31d6-360a-470a-9667-73e6e670a63a
📒 Files selected for processing (3)
.Jules/sentinel.mdTriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swiftXboxControllerMapper/XboxControllerMapper/Services/Input/UniversalControlMouseRelay.swift
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
🛡️ Sentinel: [MEDIUM] Fix Process Deadlocks
Vulnerability: Parent processes executing
Process()(NSTask) with piped standard output/error were deadlocking if the child output exceeded the OS pipe buffer size (~64KB). The parent process calledwaitUntilExit()before reading the output, causing a classic IPC deadlock.Impact: This is a DoS risk if an attacker can control or pad the output of commands executed by the application.
Fix: Always read all data from
Pipe()objects (e.g., usingreadDataToEndOfFile()) before callingprocess.waitUntilExit(). This prevents the parent process from blocking on the exit signal while the child process blocks on a full pipe buffer.Verification: The code changes were verified to fix the execution ordering issue without modifying the logic of what is read. Static verification passes.
PR created automatically by Jules for task 12262059625694813152 started by @NSEvent
Summary by CodeRabbit