Skip to content

fix: avoid statx syscall so zmx runs on pre-4.11 kernels (#186)#188

Open
offbyone wants to merge 1 commit into
neurosnap:mainfrom
offbyone:fix-avoid-statx-syscall-so-zmx-runs-on-pre-4.11-kernels-186/wzmroospokmo
Open

fix: avoid statx syscall so zmx runs on pre-4.11 kernels (#186)#188
offbyone wants to merge 1 commit into
neurosnap:mainfrom
offbyone:fix-avoid-statx-syscall-so-zmx-runs-on-pre-4.11-kernels-186/wzmroospokmo

Conversation

@offbyone

@offbyone offbyone commented Jul 8, 2026

Copy link
Copy Markdown

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).

Fixes #186

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).
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.

error: Unexpected when trying to attach a zmx session on Synology Diskstation

1 participant