Skip to content

lib: windows: _read: Call NtReadFile, rather than read - #4

Merged
aoinoikaz merged 1 commit into
windows-pe32-ntcallfrom
windows-read-bare
Nov 3, 2026
Merged

aoinoikaz merged 1 commit into
windows-pe32-ntcallfrom
windows-read-bare

Conversation

@aoinoikaz

Copy link
Copy Markdown

lib/windows/_read.c answered with read. kaem.windows.run builds read from lib/windows/read.c, the bare NtReadFile, beside the stub __buffered_read, so mes-m2 never looped. configure-lib.sh's lists build read from lib/posix/buffered-read.c instead, whose __buffered_read fills its buffer with _read (lib/mes/__buffered_read.c:97), so read, __buffered_read and _read called one another until the stack ran out. Mes compiled by MesCC died with STATUS_STACK_OVERFLOW once it had opened boot-5.scm, having printed nothing; with its whole stack committed it ran off the end with an access violation instead.

_read is now the bare NtReadFile, as lib/linux/_read.c is the bare SYS_read, and read.c, which only the build without the buffer uses, calls it. kaem.windows.run builds _read.c ahead of read.c.

The Windows CI builds and boots mes-m2 from the changed kaem.windows.run; the MesCC-built libc this fixes runs in nova-nix's Mes job.

lib/windows/_read.c answered with read, which kaem.windows.run builds
from lib/windows/read.c, the bare NtReadFile, beside the stub
__buffered_read.  configure-lib.sh's lists build read from
lib/posix/buffered-read.c instead, whose __buffered_read fills its buffer
with _read, so read, __buffered_read and _read called one another until
the stack ran out.  Mes compiled by MesCC died with STATUS_STACK_OVERFLOW
once it had opened boot-5.scm, having printed nothing.  _read is now the
bare NtReadFile, as lib/linux/_read.c is the bare SYS_read, and read.c,
which only the build without the buffer uses, calls it.

* lib/windows/_read.c (_read): Call NtReadFile, moved here from read.c.
* lib/windows/read.c (read): Call _read.
* kaem.windows.run: Build lib/windows/_read.c ahead of read.c.
@aoinoikaz
aoinoikaz merged commit cf55470 into windows-pe32-ntcall Nov 3, 2026
2 checks passed
@aoinoikaz
aoinoikaz deleted the windows-read-bare branch November 3, 2026 23:18
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