Commit Graph

36988 Commits

Author SHA1 Message Date
Andrew Kelley a520355e4c std.process: simplify RunError set 2026-01-30 22:03:14 -08:00
Andrew Kelley a41ee5994d std.Build.Step: evalZigProcess handles EndOfStream
and a happy little info log when the process needs to be restarted
2026-01-30 22:03:14 -08:00
Andrew Kelley 866ee4f1c5 std.Io.Threaded: handle TIMEOUT from NtDelayExceution 2026-01-30 22:03:14 -08:00
Matthew Lugg f8828e543a std.Build: fully upgrade Step.Run to std.Io timing (and fix a typo) 2026-01-30 22:03:14 -08:00
Matthew Lugg c2679feaaa std.Io.Threaded: fix ntdll timeouts on Windows 2026-01-30 22:03:14 -08:00
Andrew Kelley 8f8aa8346a std.Io.Threaded: ntReadFileResult handles EOF + bytes available 2026-01-30 22:03:14 -08:00
Andrew Kelley 4dd7fe90a2 std.Io.Threaded: compress ntReadFile logic
Just use the ntstatus field rather than an additional enum
2026-01-30 22:03:14 -08:00
Andrew Kelley 3320e6a1ae std.Io.Threaded.batchWait better fix for any_done
It is legal to call batchWait with already completed operations in the
ring. In such case, we need to avoid waiting in the syscall. The
any_done flag was a poor way of tracking state we already have: whether
the completion queue is empty.

This problem affects the posix poll implementation as well.

Thanks again to jacobly for finding the problem.
2026-01-30 22:03:14 -08:00
Andrew Kelley d770e14e00 std.Io.Threaded.batchWaitWindows: eager result sets any_done true
Thanks jacobly for finding the bug
2026-01-30 22:03:14 -08:00
Andrew Kelley 7a13d57916 std.Io.Threaded: add missing check for pending status in batchCancel 2026-01-30 22:03:14 -08:00
Andrew Kelley 687123a85e std.process.run: use Io.File.MultiReader
and delete the special-cased function
2026-01-30 22:03:14 -08:00
Andrew Kelley b2816f2698 build.zig: only-c implies no-lib 2026-01-30 22:03:14 -08:00
Andrew Kelley 6a1fd3c69d std.Io.File.MultiReader: make checkAnyError exclude EndOfStream 2026-01-30 22:03:14 -08:00
Andrew Kelley 8a80b54640 std: remove error.BrokenPipe from file reads, add error.EndOfStream
and make reading file streaming allowed to return 0 byte reads.
According to Microsoft documentation, on Windows it is possible to get
0-byte reads from pipes when 0-byte writes are made.
2026-01-30 22:03:14 -08:00
Andrew Kelley fdf1ee973e std.Io.Threaded: move the NtDelayExecution later in batchWait
also guard against receiving SUCCESS with 0 byte read

ms docs say that pipes can do this if there is a 0 byte write
2026-01-30 22:03:14 -08:00
Andrew Kelley 2fb224cb84 std.Io.Threaded: fix bad use of AlertableSyscall
The defer would cause two problems:
1. keeping the state active during call to NtCancelIoFile
2. invalid state transition. after canceled is returned from
   checkCancel, new status is already canceled. calling finish after
   that is illegal.
2026-01-30 22:03:14 -08:00
Andrew Kelley efa502a1cd std.Build.Step.Run: gracefully handle test runner misbehavior
specifically if it misbehaves after sending a message header but not the
body
2026-01-30 22:03:14 -08:00
Andrew Kelley 523aa213c9 std.Io.Threaded: batchWait and batchCancel for Windows 2026-01-30 22:03:14 -08:00
Andrew Kelley 37316a3cf6 std.Io.Threaded: resolve merge conflicts 2026-01-30 22:03:14 -08:00
Andrew Kelley 276ca77bf0 build: adjust max_rss for behavior tests
observed error: memory usage peaked at 0.70GB (699138048 bytes),
exceeding the declared upper bound of 0.66GB (659809075 bytes)
2026-01-30 22:03:14 -08:00
Andrew Kelley ec74d650fe incr-check: update to std.Io.File.MultiReader
from std.Io.poll
2026-01-30 22:03:14 -08:00
Andrew Kelley a901ea23b0 update doctest API usage 2026-01-30 22:03:14 -08:00
Andrew Kelley 15ca46d1e7 std.Io.Threaded: fix compilation error on some systems 2026-01-30 22:03:14 -08:00
Andrew Kelley a4d438562d std.Io.Threaded: fix compilation failures on Windows
it's still broken as hell tho
2026-01-30 22:03:14 -08:00
Andrew Kelley 54241bc770 tools: update for std.process API changes 2026-01-30 22:03:14 -08:00
Andrew Kelley 9134430387 std.Io.Threaded: fix batchWait impl 2026-01-30 22:03:14 -08:00
Andrew Kelley 68a34df025 std.Io.Threaded: fix error set 2026-01-30 22:03:14 -08:00
Andrew Kelley 372e8e54d3 compiler: update for std.Io.File.MultiReader API 2026-01-30 22:03:14 -08:00
Andrew Kelley dd0153b91b std.Io.operate: fix bogus catch
this used to have a different error set. just goes to show you how
useful switching on error set is even when there is only 1 prong
2026-01-30 22:03:14 -08:00
Andrew Kelley e56563ce3f std.Io.File.MultiReader: implementation fixes 2026-01-30 22:03:14 -08:00
Andrew Kelley 12cfc96e1b std: update rest of build runner to new File.MultiReader API 2026-01-30 22:03:14 -08:00
Andrew Kelley 20cadd60aa std.Io.File: introduce MultiReader
Concurrently read from multiple file streams, eliminating risk of
deadlocking.
2026-01-30 22:03:14 -08:00
Andrew Kelley a0c2645948 std.Io.Threaded: delete dead code 2026-01-30 22:03:14 -08:00
Andrew Kelley 78a1476475 Build.WebServer: update concurrency API usage 2026-01-30 22:03:14 -08:00
Jacob Young 8146ccfecc Io: add ring to Batch API 2026-01-30 22:03:14 -08:00
Andrew Kelley 0a379513af std.Io.Threaded: super broken Windows impl of batch
this is a cry for help
2026-01-30 22:03:14 -08:00
Andrew Kelley 23d25dbb9e std.process.Child.collectOutput: change back to other impl
this one avoids calling poll() more than necessary
2026-01-30 22:03:14 -08:00
Andrew Kelley 642f329ac9 std.Io: exploring a different batch API proposal 2026-01-30 22:03:14 -08:00
Andrew Kelley e2a266e744 Revert "std.process.Child: rewrite using concurrent"
This reverts commit 76e1ba8f490812c6e2ebf6f6becd89a71275d21e.
2026-01-30 22:03:13 -08:00
Andrew Kelley 87408f8add std.process.Child: rewrite using concurrent
I plan to immediately revert this, but here's a commit for posterity
2026-01-30 22:03:13 -08:00
Andrew Kelley b996675dcf fix error set 2026-01-30 22:03:13 -08:00
Andrew Kelley e0d06b40e3 std.Io.Threaded: set poll_buffer_len to 32
reasoning is that polling with large amount of operations will be rarely
done with std.Io.Threaded. However this still provides the opportunity
to provide concurrency for any real world use cases that need it.
2026-01-30 22:03:13 -08:00
Andrew Kelley 6a7fe61d74 std.Io.Threaded.operate: handle poll buffer exceeded 2026-01-30 22:03:13 -08:00
Andrew Kelley 93f5c99149 std.Io.Threaded.operate: handle cancelation and poll errors 2026-01-30 22:03:13 -08:00
Andrew Kelley 05064e1281 std.Io: simplify operate function
- no timeout
- no n_wait
- infallible
2026-01-30 22:03:13 -08:00
Andrew Kelley 0a0ecc4fb1 std.Io: proof-of-concept "operations" API
This commit shows a proof-of-concept direction for std.Io.VTable to go,
which is to have general support for batching, timeouts, and
non-blocking.

I'm not sure if this is a good idea or not so I'm putting it up for
scrutiny.

This commit introduces `std.Io.operate`, `std.Io.Operation`, and
implements it experimentally for `FileReadStreaming`.

In `std.Io.Threaded`, the implementation is based on poll().

This commit shows how it can be used in `std.process.run` to collect
both stdout and stderr in a single-threaded program using
`std.Threaded.Io`.

It also demonstrates how to upgrade code that was previously using
`std.Io.poll` (*not* integrated with the interface!) using concurrency.
This may not be ideal since it makes the build runner no longer support
single-threaded mode. There is still a needed abstraction for
conveniently reading multiple File streams concurrently without
io.concurrent, but this commit demonstrates that such an API can be
built on top of the new `std.Io.operate` functionality.
2026-01-30 22:03:13 -08:00
Andrew Kelley bd4b6d8b14 std.Io: delete the poll API 2026-01-30 22:03:13 -08:00
Jacob Young 90890fcb5c Io.Threaded: fix UAF-induced crashes during asynchronous operations
When `NtReadFile` returns `SUCCESS`, the APC routine still runs when
next alertable, which was previously clobbering an out of scope `done`.
Instead of adding an extra syscall to the success path, avoid all APC
side effects, allowing instant completions to return immediately.
2026-01-30 22:03:13 -08:00
Andrew Kelley 9862518797 std.Io.Threaded: fix NtDelayExecution delay interval 2026-01-30 22:03:13 -08:00
Andrew Kelley 11b0a504df std.Io.Threaded: handle some more error codes from NtReadFile 2026-01-30 22:03:13 -08:00