Skip to content

fix: short writes, lock gates, and interrupted /proc scans - #3

Merged
HaoZeke merged 8 commits into
mainfrom
fix/safety
Nov 16, 2026
Merged

HaoZeke merged 8 commits into
mainfrom
fix/safety

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Short writes, lock gates, interrupted scans, and a few related error paths are tightened, and COMPAT.md names errno 133 as the hardware-error text.

  • fgetxattr was not retried on EINTR, so a signal refused the replacement. atomicWrite also leaked the temporary path, the step names, and the spare ACL read. The ACL read is retried, and the scratch is freed.
  • copyTo truncated the destination before the write finished, so a full disk or a file-size limit destroyed an existing file. appendLine could leave a partial line. copyTo now renames new bytes into place, and appendLine rolls a short write back to the size before it.
  • lockExclusive could treat a signal that cut a sleep short as a timeout. RootLock accepted a gate or sidecar that was not a regular file of this user with one link. The deadline is read from the monotonic clock, and a foreign gate is refused.
  • decodeCache and key comparison read past a string that ended on a backslash. They now return an encoding error and free the bytes allocated before that error.
  • pySplit abandoned its list when allocation failed, and the slice it returned was not the whole allocation, so a caller could not free it. The list is freed on the error path.
  • A crash or a short write could leave a partial name.gz that a later run skipped. The archive is written under a temporary name and renamed after it is synced.
  • groupAlive treated EINTR from getdents as "nobody is alive", so waitGroupGone could return while the group was still running. A signal during the scan is not an empty group.
  • COMPAT.md said errno 134 was the unnamed hardware-error text. On x86_64 that text is errno 133, HWPOISON, which Zig names; 134 is unnamed, as glibc prints it. The module summary matches the copy and the lock gate.

The atomic-write commit says its tests use std.testing.allocator. The docs commit checks that describe prints [Errno 133] Memory page has hardware error and [Errno 134] Unknown error 134, and that COMPAT.md names errno 133. Each of the fix and docs commits has a towncrier fragment, and the branch adds towncrier.toml.

fgetxattr was not retried on EINTR, so a signal refused the replacement.
atomicWrite also leaked the temporary path, the step names and the spare
ACL read. Tests cover both under std.testing.allocator.
copyTo renames the new bytes into place, so a full disk or a file-size
limit leaves an existing file unchanged. appendLine rolls a short write
back to the size before it, so the line list does not gain a partial line.
lockExclusive reads its deadline from the monotonic clock, so a signal
that cuts a sleep short does not expire the wait. RootLock refuses a gate
or sidecar that is not a regular file of this user with one link.
decodeCache and key comparison read past a string that ended on a
backslash. They now return an encoding error, and the bytes allocated
before that error are freed.
The list was abandoned on the error path, and the slice it returned was
not the whole allocation, so a caller could not free it.
The archive is written under a temporary name, synced and renamed. A
crash or a short write no longer leaves a partial name.gz that a later
run skips.
groupAlive treated EINTR from getdents as "nobody is alive", so
waitGroupGone could return while the group was still running.
COMPAT.md said errno 134 was the unnamed hardware-error text. On x86_64
that text is errno 133, HWPOISON, which Zig names; 134 is unnamed, as
glibc prints it. The module summary matches the copy and the lock gate.
@HaoZeke
HaoZeke merged commit 1c09e91 into main Nov 16, 2026
8 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