kovidgoyal/kitty · error
Failed to write to SHM file with error: %w
Error message
Failed to write to SHM file with error: %w
What it means
After creating the SHM file, RunSSHAskpass writes the JSON request with shm.WriteWithSize at offset 1 (offset 0 is the ready flag). If that write fails (mapping too small, mmap error, I/O error), this fatal error is returned.
Source
Thrown at kittens/ssh/askpass.go:139
q := map[string]any{
"message": msg,
"type": q_type,
"is_password": !is_fingerprint_check,
}
data, err := json.Marshal(q)
if err != nil {
return fatal(err)
}
data_shm, err := shm.CreateTemp("askpass-*", uint64(len(data)+32))
if err != nil {
return fatal(fmt.Errorf("Failed to create SHM file with error: %w", err))
}
defer data_shm.Close()
defer func() { _ = data_shm.Unlink() }()
data_shm.Slice()[0] = 0
if err = shm.WriteWithSize(data_shm, data, 1); err != nil {
return fatal(fmt.Errorf("Failed to write to SHM file with error: %w", err))
}
if err = data_shm.Flush(); err != nil {
return fatal(fmt.Errorf("Failed to flush SHM file with error: %w", err))
}
trigger_ask(data_shm.Name())
for {
time.Sleep(50 * time.Millisecond)
if data_shm.Slice()[0] == 1 {
break
}
}
data, err = shm.ReadWithSize(data_shm, 1)
if err != nil {
return fatal(fmt.Errorf("Failed to read from SHM file with error: %w", err))
}
response := ""
if is_confirm {
var ok boolView on GitHub (pinned to 6d5d0c4406)
Solutions
- Verify /dev/shm is a real tmpfs
- Check dmesg for mmap/SHM errors
- Retry; if persistent, report with the wrapped error details
Defensive patterns
Strategy: try-catch
Try / catch
if err := shm.WriteWithSize(f, data, 1); err != nil { /* log, close, unlink, abort askpass */ } Prevention
- Size SHM allocations generously (payload + header)
- Verify tmpfs backing before use
When it happens
Trigger: SHM file created with insufficient size for the payload, or mmap write failure on the shared memory region.
Common situations: Odd filesystem backing for /dev/shm that does not support the mmap semantics, or a truncated CreateTemp size due to integer issues.
Related errors
- Failed to create SHM file with error: %w
- Failed to flush SHM file with error: %w
- Failed to read from SHM file with error: %w
- Failed to parse response data: %#v with error: %w
- Incorrect owner on pwfile: uid={shm.stats.st_uid} gid={shm.s
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/dc65625b9f4a736e.
Report an issue: GitHub.