anomalyco / anomalyco/opencode
Zero-length file writes fail with EFAULT on aarch64 Linux — sessions in git projects die instantly
@kitlangton is already working on this.
Since Aug 4, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
On aarch64 Linux (Kylin V10 SP1, kernel 5.10.97, arm64), opening a session in any directory that belongs to a git repository dies immediately: the prompt is sent, a title is generated, thinking starts, then nothing is ever returned. The server log shows prompt_async failed with EFAULT from FileSystem.writeFile on snapshot/<projectID>/<hash>/info/exclude. Non-git directories work fine.
Root cause: this kernel validates the write(2) buffer pointer even when count == 0. The data pointer of Node/V8 zero-length Buffer/Uint8Array (empty backing store sentinel) is not a valid userspace address here, so every zero-length fs.writeFile fails with EFAULT. Snapshot init writes an empty info/exclude (writeFileString(target, text ? text+"\n" : "")), which always triggers it; the session lock heartbeat (another zero-length write) fails the same way.
strace of the server process while reproducing:
openat(AT_FDCWD, ".../snapshot/<id>/<hash>/info/exclude", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 58
write(58<.../info/exclude>, "", 0) = -1 EFAULT
write(45<.../locks/<hash>.lock/heartbeat>, "", 0) = -1 EFAULT
Control test on the same machine: write(fd, NULL, 0) and write(fd, (void*)1, 0) both return 0 — only Node's empty-buffer sentinel pointer faults.
Suggested fix: guard zero-length data in the FileSystem.writeFile implementation — either skip the write syscall for empty data (open+truncate+close yields the same empty file), or pass a zero-length view over a real allocation, e.g. Buffer.alloc(1).subarray(0, 0). I verified the second variant by patching it into app.asar locally; snapshot init and git-project sessions then work normally.
This is arguably also a Node.js bug (empty Buffer/Uint8Array should not hand the sentinel pointer to write(2)), but an opencode-side guard fixes it regardless of runtime behavior.
Plugins
N/A (reproduced with plugins disabled)
OpenCode version
Desktop 1.18.12 (Node v24.15.0 runtime)
Steps to reproduce
- Use aarch64 Linux with a kernel that validates the write pointer for
count == 0(Kylin V10 SP1 confirmed). - Open any directory that is (or is inside) a git repository.
- Send any message → session dies (
prompt_async failed,EFAULT).
Operating System
Kylin Linux V10 SP1, aarch64, kernel 5.10.97-33-9000c
Terminal
N/A (OpenCode Desktop)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.