Skip to content

Windows: an OS error's text is strerror of a Win32 code (ERROR_INVALID_NAME 123 prints "no protocol option"); rt_readlink returns "" #2773

Closed

Description

@ehartford

Found 2026-10-28 on win10 (branch fix-809) running :cli-selfhost-build-w-tests:

read_text: C:/…/out/archive/extracted/pkg/link-a.txt: no protocol option (os error 123); reached through __with_build_eval_entry -> build

123 is Win32 ERROR_INVALID_NAME (the symlink target was spelled with /; fixed separately in rt_symlink). The text is POSIX strerror(123) (ENOPROTOOPT).

Exact lines.

  • rt/windows_x86_64.w:231 win_error() returns GetLastError(); the fs wrappers return its negation, so IoError.Os(code) holds a Win32 code on Windows.
  • lib/std/fs.w:63 IoError.message and src/ComptimeEval.w:546 comptime_os_error_message format every code with strerror(code), which reads it as an errno.

Fix. The runtime owns the text: a per-platform with_os_error_text(code) -> str (strerror on POSIX, FormatMessageW on Windows), read by IoError.message. src/ComptimeEval.w reaches it after a seed carries it (seed-bound: src/ links the pinned seed's runtime).

Also on Windows: rt_readlink (rt/windows_x86_64.w, rt/windows_aarch64.w) is let _ = path; win_empty_str(). That's a silent stub: every readlink on Windows answers "" instead of the target or an error. It needs DeviceIoControl(FSCTL_GET_REPARSE_POINT) or GetFinalPathNameByHandleW, or a loud refusal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions