-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Description
Sidecar crashes or hangs immediately on startup when running in a repository with hierarchical branch names (e.g., feat/ui) or when multiple conversation adapters are enabled.
Symptoms
- Immediate Crash (Segfault or Panic):
panic: runtime error: invalid memory addressin workspace pluginfatal error: concurrent map writesin OpenCode adapter
- Infinite Hang:
- Application freezes on startup "loading sessions..."
ps auxshows thousands ofgitprocesses (zombies or active)
- Resource Exhaustion:
syscall.forkExecfailures due to file descriptor exhaustion
Root Cause Analysis
After deep investigation, we identified 5 distinct bugs contributing to this instability:
1. Worktree Path Construction Failure
Location: internal/plugins/workspace/worktree.go
Cause: When creating a worktree for a branch with slashes (e.g., feat/ui), the code used the raw branch name as the directory name.
filepath.Join(parent, "feat/ui") -> /path/to/parent/feat/ui.
Since the feat/ directory doesn't exist in the parent, the git worktree add command fails or causes internal logic to panic.
2. Concurrent Map Write in OpenCode Adapter
Location: internal/adapter/opencode/adapter.go
Cause: The sessionIndex map was being written to by multiple goroutines concurrently during parallel session loading.
Finding: This map was actually dead code—it was populated but never read.
3. Process Exhaustion in Default Branch Detection
Location: internal/plugins/workspace/diff.go
Cause: detectDefaultBranch spawns 1-3 git processes every time it's called. It is called frequently (e.g., on every update tick).
Effect: Spawns thousands of git processes per minute, exhausting file descriptors (syscall.forkExec fails).
4. Infinite Hangs (Missing Timeouts)
Locations: internal/plugins/gitstatus/tree.go, internal/plugins/conversations/plugin_loading.go
Cause:
git statuscommands can hang indefinitely on large repos.- Adapter
Sessions()calls (e.g. Cursor) can hang indefinitely. - The loader waited on a
WaitGroupwithout a timeout, causing a permanent freeze if any single adapter hung.
5. Cursor Adapter Malformed JSON Crash
Location: internal/adapter/cursor/adapter.go
Cause: json.Unmarshal panic/error when encountering malformed messages in Cursor chat history.
Fix
A comprehensive fix has been implemented in PR #136 which addresses all these issues:
- Sanitizes worktree directory creation (ensures parent dirs exist)
- Removes thread-unsafe dead code
- Caches default branch detection
- Adds timeouts to all external command execution
- Adds defensive error handling for JSON parsing
Metadata
Metadata
Assignees
Labels
Projects
Status