Skip to content

Keep the original errno in atomic-write and lock errors - #84

Merged
HaoZeke merged 4 commits into
developfrom
fix/zc75-fix-forward
Nov 24, 2026
Merged

HaoZeke merged 4 commits into
developfrom
fix/zc75-fix-forward

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #75, which merged with three problems in its error reporting.

  • A blocking record lock (F_SETLKW) treated EAGAIN and EACCES as unexpected, so describe printed an I/O error while the snapshot said permission denied. It now returns the mapped error: EAGAIN stays unexpected and EACCES becomes AccessDenied.
  • A failed stat or unlink of the temporary file during replacement cleanup overwrote sys.last_errno after the OSError text was built, so a later describe reported the cleanup error. The original errno is now kept, in atomicWriteAt as well. Tests make the cleanup fail with a different errno and check that the original survives.
  • osFailure returns slices of thread-local storage. Its new doc comment says the next acquire on the same thread reuses them.

The parity probe now prints the full atomic-write diagnostic and the state lock's text and path. The Python test triggers open, write, rename, missing-parent, permission, lock-file and POSIX sidecar failures and compares the text with the OSError Python raises for the same call.

The parity probe reported only the Zig error name when an atomic
write failed, and it never acquired a state lock. A wrong path or a
dropped OSError text could not be seen from Python.

Print the full atomic-write diagnostic, and the state lock's text
and path. The test raises open, write, rename, missing-parent,
permission, lock file and POSIX sidecar failures, and compares that
text with the OSError Python raises for the same call.

Cleanup restores a mode-0555 directory before removing it, and a
write-fsize skip no longer requires the process to run as root.
A failed stat or unlink of the temporary file runs after the OSError
text has been built. That cleanup used to replace sys.last_errno, so
a later describe saw the cleanup error instead of the original one.
atomicWriteAt's cleanup unlink keeps it the same way. Tests make that
cleanup fail with a different errno and require the original to remain.
osFailure returns slices of thread-local storage and had no doc
comment, so the generated API page did not say that the next acquire
on the same thread reuses them.
F_SETLKW treated EAGAIN and EACCES as Unexpected. describe of that
error ignores EACCES and prints an I/O error, while the snapshot kept
permission denied. Return the mapped error so the two agree: EAGAIN
stays Unexpected and EACCES is AccessDenied.
@HaoZeke
HaoZeke merged commit 3e17752 into develop Nov 24, 2026
8 checks passed
@HaoZeke
HaoZeke deleted the fix/zc75-fix-forward branch November 24, 2026 16:20
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