fix: avoid statx syscall so zmx runs on pre-4.11 kernels (#186)#188
Open
offbyone wants to merge 1 commit into
Open
Conversation
zmx crashed with `error: Unexpected` on every invocation on a Synology
DiskStation (Linux 4.4.302). `error.Unexpected` is what Zig's std returns
for an unrecognized errno; here the errno is ENOSYS (38) from the `statx`
syscall, which only exists on Linux >= 4.11.
Two code paths issued statx via Zig std, which calls the raw statx syscall
directly and does not fall back like libc does:
- log.zig: LogSystem.init() called file.getEndPos() -> File.stat() -> statx.
This runs before command parsing, so it broke *every* subcommand, not
just attach.
- socket.zig: sessionExists() called Dir.statFile() -> statx.
Both now use fd/at-based stat instead:
- LogSystem.init() uses posix.fstat(file.handle).
- sessionExists() uses posix.fstatatZ() + S.ISSOCK().
Because zmx links musl, these resolve to SYS_fstat / SYS_fstatat (musl on
x86_64 skips statx entirely), which are available on 4.4. Verified by
disassembling the release binary: no reachable statx call remains on the
attach path (the only residual references are the DWARF stack-trace
unwinder and sendFile fast-paths, neither of which zmx exercises).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zmx crashed with
error: Unexpectedon every invocation on a Synology DiskStation (Linux 4.4.302).error.Unexpectedis what Zig's std returns for an unrecognized errno; here the errno is ENOSYS (38) from thestatxsyscall, which only exists on Linux >= 4.11.Two code paths issued statx via Zig std, which calls the raw statx syscall directly and does not fall back like libc does:
Both now use fd/at-based stat instead:
Because zmx links musl, these resolve to SYS_fstat / SYS_fstatat (musl on x86_64 skips statx entirely), which are available on 4.4. Verified by disassembling the release binary: no reachable statx call remains on the attach path (the only residual references are the DWARF stack-trace unwinder and sendFile fast-paths, neither of which zmx exercises).
Fixes #186