Segfault on Windows git bash (msys) when using bash tool with cwd #7880

Open
opened 2026-02-16 18:08:33 -05:00 by yindo · 2 comments
Owner

Originally created by @pschiel on GitHub (Jan 28, 2026).

Originally assigned to: @rekram1-node on GitHub.

Steps to reproduce

  • use git bash
  • ask agent to run bash tool, given an absolute path
  • bash will fail with ENOENT and bun crashing

Root cause

In a Windows environment with mixed paths (Windows, MSYS/GitBash), bun spawn will crash with segfault when cwd is passed using backslashes

#6763 solves this via path normalization

Originally created by @pschiel on GitHub (Jan 28, 2026). Originally assigned to: @rekram1-node on GitHub. ## Steps to reproduce - use git bash - ask agent to run bash tool, given an absolute path - bash will fail with `ENOENT` and bun crashing ## Root cause In a Windows environment with mixed paths (Windows, MSYS/GitBash), bun `spawn` will crash with segfault when `cwd` is passed using backslashes #6763 solves this via path normalization
yindo added the windowsbug labels 2026-02-16 18:08:33 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 28, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10871: Windows: Git Bash auto-detection derives invalid bash.exe path (related issue with Git Bash path handling on Windows)
  • #10538: Ctrl-C doesn't clear the input on Windows, it crashes (another Windows bash/PTY issue)

The root cause appears to be related to Windows path handling (backslashes) in the bash tool's cwd parameter. Issue #10871 specifically addresses path handling issues with Git Bash on Windows that could be related.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 28, 2026): This issue might be a duplicate of existing issues. Please check: - #10871: Windows: Git Bash auto-detection derives invalid bash.exe path (related issue with Git Bash path handling on Windows) - #10538: Ctrl-C doesn't clear the input on Windows, it crashes (another Windows bash/PTY issue) The root cause appears to be related to Windows path handling (backslashes) in the bash tool's cwd parameter. Issue #10871 specifically addresses path handling issues with Git Bash on Windows that could be related. Feel free to ignore if none of these address your specific case.
Author
Owner

@pschiel commented on GitHub (Jan 31, 2026):

details:

  • segfault occurs in spawn() via Node's child_process module
  • libuv layer: when spawn() tries to change to a non-existent directory, the underlying uv_spawn call dereferences a null pointer
  • Bun doesn't validate cwd exists before attempting the spawn operation
  • Segfault at 0x0: The null pointer dereference causes immediate segfault at address 0x0

added isDir checks in bash tool, pty and lsp (where user/agent input could happen) to avoid this

@pschiel commented on GitHub (Jan 31, 2026): details: - segfault occurs in `spawn()` via Node's `child_process` module - `libuv` layer: when `spawn()` tries to change to a non-existent directory, the underlying `uv_spawn` call dereferences a null pointer - Bun doesn't validate `cwd` exists before attempting the spawn operation - Segfault at 0x0: The null pointer dereference causes immediate segfault at address 0x0 added isDir checks in bash tool, pty and lsp (where user/agent input could happen) to avoid this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7880