Skip to content

Fix a process abort when several large files are read at once - #56

Merged
olerast67 merged 1 commit into
mainfrom
fix-readahead-crash
Nov 10, 2026
Merged

olerast67 merged 1 commit into
mainfrom
fix-readahead-crash

Conversation

@olerast67

Copy link
Copy Markdown
Owner

zamok-core could abort (0xc0000409) when two or more large files were read at the same time: the read-ahead job re-entered decrypt_range on a pool thread that already held the thread-local ciphertext buffer, panicked with "RefCell already borrowed", and a panic in rayon::spawn aborts the process. This is the intermittent zamok-fs --lib CI failure.

  • the buffer is taken out of the thread-local for the call instead of borrowed;
  • the read-ahead job catches panics and reports a failed prefetch, the read then goes the normal way;
  • new test parallel_large_reads_of_many_files_do_not_crash: aborted 5/5 before, passes 8/8 after.

cargo fmt, clippy, cargo test workspace, tests/fs/test-fs.ps1 33/33.

🤖 Generated with Claude Code

decrypt_range borrowed the per-thread ciphertext buffer and held the
borrow across pool().install. While a pool thread waits for its chunks
there it runs other jobs, including another file's read-ahead, which
re-entered decrypt_range on the same thread: "RefCell already borrowed",
and a panic inside rayon::spawn aborts the whole process (0xc0000409,
seen in CI). The buffer is now taken out of the thread for the call and
put back after, and the read-ahead job catches panics and falls back to
a normal read. New test reads 8 files in parallel; it aborted 5 of 5
runs before the fix and passes 8 of 8 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@olerast67
olerast67 merged commit 7126ad1 into main Nov 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant