Commit Graph

14170 Commits

Author SHA1 Message Date
Andrew Kelley 2b326d27d5 std.Io.Threaded: improve various Windows logic
* cache nul handle for child process execution
* make opening the nul file integrate properly with cancelation
* replace all calls to SleepEx to parking_sleep.sleep instead, making
  them properly cancelable. These sleeps are workarounds for Windows
  kernel bugs. Now you can even cancel while waiting for kernel bug
  workarounds!
2026-01-04 00:27:09 -08:00
Andrew Kelley be977e1934 std.Io.Threaded: integrate with new cancel mechanism 2026-01-04 00:27:09 -08:00
Andrew Kelley ff67f70cf9 start: tweak default allocator choices
On wasm targets, when libc is linked, we have to go through libc.
2026-01-04 00:27:09 -08:00
Andrew Kelley e23d980e11 std.process.Environ: skip BE createMapWide test coverage
it would be good to fix this but master branch doesn't have coverage
either. one thing at a time.
2026-01-04 00:27:09 -08:00
Andrew Kelley e2c04a4651 fix some windows compilation errors 2026-01-04 00:27:09 -08:00
Andrew Kelley 2fee64ceb0 update init template for new main API 2026-01-04 00:27:09 -08:00
Andrew Kelley dd7be75f7c std.process: add missing error.OperationUnsupported 2026-01-04 00:27:09 -08:00
Andrew Kelley baa49e5929 std.Io.Threaded: implement processReplace 2026-01-04 00:27:09 -08:00
Andrew Kelley 08cc9e8d59 std.Io.Threaded: std.process -> process 2026-01-04 00:27:09 -08:00
Andrew Kelley b32a38ad27 build: fix file system watching compilation on macOS 2026-01-04 00:27:09 -08:00
Andrew Kelley 1070c2a71a rename env_map to environ_map
For naming consistency with `std.process.Environ.Map`.
2026-01-04 00:27:09 -08:00
Andrew Kelley f25de4c7a2 fix native path lookup on macOS 2026-01-04 00:27:08 -08:00
Andrew Kelley c6b75b61b7 std: fix child processes on riscv32-linux 2026-01-04 00:27:08 -08:00
Andrew Kelley d97e4ca0d1 documentation should be descriptive not prescriptive 2026-01-04 00:27:08 -08:00
Andrew Kelley 4afed3e9ef test-standalone: update the rest of the cases to new API 2026-01-04 00:27:08 -08:00
Andrew Kelley e149c0e2aa std.Build.Step.Run: fix wrong environment passed 2026-01-04 00:27:08 -08:00
Andrew Kelley af164b3f3c std.Build.Step.Run: no need to sort the environment
since we now use ArrayHashMap, the order is deterministic, and in fact,
observable by applications.
2026-01-04 00:27:08 -08:00
Andrew Kelley ca5c5ade5f std.Options: work around not lazy enough compiler 2026-01-04 00:27:08 -08:00
Andrew Kelley bf74827ddb test-standalone: update more cases to new main API 2026-01-04 00:27:08 -08:00
Andrew Kelley 1b56686012 test-standalone: update cases to new main API 2026-01-04 00:27:08 -08:00
Andrew Kelley f2cf7b538f std.Io.Threaded: fix the child process error fd mechanism 2026-01-04 00:27:08 -08:00
Andrew Kelley 0ca83dd9d2 start: fix compilation with -lc on windows 2026-01-04 00:27:08 -08:00
Andrew Kelley 85fe35d246 compiler: fix -Denable-llvm compilation failures 2026-01-04 00:27:08 -08:00
Andrew Kelley f28802a9c6 zig libc: fix subcommand
This branch regressed the child process "run" mechanism because it
didn't pass the correct stdin, stdout, stderr values to process.spawn

Fixed now.
2026-01-04 00:27:08 -08:00
Andrew Kelley 960c512efd compiler: update std lib API usage 2026-01-04 00:27:08 -08:00
Andrew Kelley a6f519c20f std.process.Args: make toSlice require arena allocation
this simplifies the implementation, allows specializing it, and allows
deleting the corresponding free function. In practice this is how it is
always used anyway.
2026-01-04 00:27:08 -08:00
Andrew Kelley 1ccc87363a std: fixes for WASI 2026-01-04 00:27:08 -08:00
Andrew Kelley 50e185b718 start: tweak allocator choice
Favor DebugAllocator in Debug mode, even when linking libc. Prevent use
of smp_allocator when single_threaded
2026-01-04 00:27:08 -08:00
Andrew Kelley 0362d9f321 start: make leaks into warnings
I think it will be less confusing if memory leak checking doesn't change
the return code of the process.
2026-01-04 00:27:08 -08:00
Andrew Kelley 60447ea97c std: fix windows compilation errors 2026-01-04 00:27:08 -08:00
Andrew Kelley 08447ca47e std.fs.path: make relative a pure function
Instead of querying the operating system for current working directory
and environment variables, this function now accepts those things as
inputs.
2026-01-04 00:27:08 -08:00
Andrew Kelley b64491f2d6 compiler_rt: ensure no std.Io used when not testing 2026-01-04 00:27:08 -08:00
Andrew Kelley 9009ab2495 std.Io.Threaded: make environ init non-optional
and argv0 on systems that need it too.

fixes surprising behavior for applications that forget to initialize the
environment field.
2026-01-04 00:27:08 -08:00
Andrew Kelley de8c4cd64e compiler: update to new std.process APIs 2026-01-04 00:27:08 -08:00
Andrew Kelley 69d07472a1 std lib tests passing on linux 2026-01-04 00:27:08 -08:00
Andrew Kelley 3e6d6150d9 std.process.Environ: fix compile errors on POSIX 2026-01-04 00:27:08 -08:00
Andrew Kelley 384bfc5f99 std.Progress: go through Io interface for parent IPC mechanism
and fix start code
2026-01-04 00:27:08 -08:00
Andrew Kelley 42988fc5f4 std.process.Environ.Block: enhance type safety 2026-01-04 00:27:08 -08:00
Andrew Kelley b85524d0c8 std.process.Environ: fix contains function 2026-01-04 00:27:08 -08:00
Andrew Kelley 32af0f6154 std: move child process APIs to std.Io
this gets the build runner compiling again on linux

this work is incomplete; it only moves code around so that environment
variables can be wrangled properly. a future commit will need to audit
the cancelation and error handling of this moved logic.
2026-01-04 00:27:08 -08:00
Andrew Kelley d6a1e73142 std: start wrangling environment variables and process args
this commit is unfinished. It marks a spot where I wanted to start
moving child process stuff below the std.Io.VTable
2026-01-04 00:27:07 -08:00
Rue04 86a9a9048e std.MultiArrayList: add *Bounded variants and initCapacity
Because I accidentially squished two commit and can't figure out how to separate them
again, this also
- standardizes some doc-comments
- makes a slight change to `std.ArrayList`'s `initCapacity`'s doc-comment
2026-01-04 03:05:34 +01:00
Matthew Lugg 0cbaaa5eb9 std.Thread: stop clobbering syscall args
TL;DR: "r" considered harmful.

If LLVM chose registers badly, the inline asm which cleans up a thread
on Linux could, on all architectures other than x86_64, clobber either
`munmap` argument with the other argument *or* with the syscall number.
This would cause munmap to return EINVAL, and we would literally *never*
free the thread memory, which isn't ideal.

As it turns out, this was happening on MIPS, and was the cause of the
failures we've recently been seeing for that target: QEMU genuinely was
running out of memory (or at least, the virtualized address space was
getting too fragmented to map many contiguous pages). I've therefore
re-enabled a test which was disabled due to that flakiness.

This bug was accidentally fixed for x86_64 back in 2022 (see 59e33b447),
which probably helped it to go unnoticed for as long as it did!

Resolves: https://codeberg.org/ziglang/zig/issues/30216
2026-01-04 01:35:27 +01:00
Andrew Kelley a0a982f0ea std.crypto.kangarootwelve: disable flaky test
tracked by #30676
2026-01-03 16:27:09 -08:00
Matthew Lugg f7f0b9d28f std.http.test: fix memory leaks on OOM 2026-01-03 15:45:11 +00:00
Matthew Lugg 3bb2f7b84e std.Io.net: don't swallow 'error.Canceled'
This was missed when updating to the new group cancelation API, and
caused illegal behavior in many cases (the condition was simply that a
DNS query returned a second result before a connection was successfully
established).
2026-01-03 15:45:11 +00:00
Matthew Lugg f306a9f84a std: rebase fixups and cancelation changes
This commit includes some API changes which I agreed with Andrew as a
follow-up to the recent `Io.Group` changes:

* `Io.Group.await` *does* propagate cancelation to group tasks; it then
  waits for them to complete, and *also* returns `error.Canceled`. The
  assertion that group tasks handle `error.Canceled` "correctly" means
  this behavior is loosely analagous to how awaiting a future works. The
  important thing is that the semantics of `Group.await` and
  `Future.await` are similar, and `error.Canceled` will always be
  visible to the caller (assuming correct API usage).

* `Io.Group.awaitUncancelable` is removed.

* `Future.await` calls `recancel` only if the "child" task (the future
  being awaited) did not acknowledge cancelation. If it did, then it is
  assumed that the future will propagate `error.Canceled` through
  `await` as needed.
2026-01-03 15:45:11 +00:00
Matthew Lugg b8a09bcbd9 std.Io.Group: tweak documentation and vtable API 2026-01-03 15:45:11 +00:00
Matthew Lugg 2c395e326f std.Io.Threaded: always use robust cancelation
As of this branch, the performance impact of robust cancelation is now
negligible (and in fact entirely unmeasurable in almost all cases), so
there is no good reason to not enable it in all cases. The performance
issues before were primarily down to a typo in the robust cancelation
logic which resulted in every canceled syscall potentially being sent
hundreds of signals in quick succession, because the delay between
signals started out at 1ns instead of 1us!
2026-01-03 15:45:10 +00:00
Matthew Lugg f27134d671 std.Io: more tests 2026-01-03 15:45:10 +00:00