Commit Graph

13276 Commits

Author SHA1 Message Date
murtaza 07b49c61ff audit: handle process.Child.Term exhaustively and give useful exit information 2026-04-07 10:27:01 +02:00
Techatrix be878b87c2 std.EnumSet: add back deprecated initialization functions 2026-04-06 15:54:47 +02:00
Samuel Fiedler 5ec8e45f3d Io: add failing io (Io.failing) 2026-04-06 14:25:44 +02:00
glowsquid fd2718f82a fix positional reader discarding (#31593)
closes #30151
closes #30126

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31593
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
Co-authored-by: glowsquid <sachabarsayuracko@gmail.com>
Co-committed-by: glowsquid <sachabarsayuracko@gmail.com>
2026-04-06 02:03:11 +02:00
Andrew Kelley 8bd0af5eb9 std.http.Client.receiveHead: avoid poisioning pool
closes #30165
2026-04-05 15:02:00 +02:00
Andrew Kelley 9292ded5a3 std.Io.Batch: fix add function
closes #31730
closes #31757
2026-04-05 02:17:53 -07:00
nektro e73257dec2 lib/std: BitSet,EnumSet: replace initEmpty/initFull with decl literals (#31469)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31469
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: nektro <hello@nektro.net>
Co-committed-by: nektro <hello@nektro.net>
2026-04-05 05:12:13 +02:00
Saurabh Mishra 65fe99e18a priority queue and dequeue: use *const Self in read-only methods and fix deinit (#31712)
Read-only methods `peek` in priority queue, and `peekMin` and `peekMax` in priority dequeue use `self: *const Self` instead of `self: *Self`.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31712
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Saurabh Mishra <saurabh.m@proton.me>
Co-committed-by: Saurabh Mishra <saurabh.m@proton.me>
2026-04-03 22:20:46 +02:00
Kendall Condon d8ba173e5e multiprocess fuzzing
- New Features

-- Multiprocess Fuzzing

The fuzzer now is able to utilize multiple cores. This is controllable
with the `-j` build option. Limited fuzzing still uses one core.

-- Fuzzing Infinite Mode

When provided multiple tests, the fuzzer now switches between them and
prioritizes the most effective and interesting ones. Over time already
explored tests will become barely run compared to tests yielding new
inputs.

-- Crash Dumps

Crashing inputs are now saved to a file indicated by the crash message.
It is recommended to use these files to reproduce the crash using
`std.testing.FuzzInputOptions.corpus` and @embedFile.

- Design

Each fuzzing process is assigned an instance id which has the following
uses:
* In conjunction with the pc hash and running test index, they uniquely
  identify input files in the case of a crash.
* It is combined with the test seed for a unique rng seed.
* Instance 0 is solely responsible for syncing the filesystem corpus.

When new inputs are found, they are sent to the build server. It then
distributes the new input to the other instances. Each instance has a
concurrent poller managed by the test runner which sends received
inputs to libfuzzer. (note that this is affected by #31718 and so can
(rarely) deadlock)

For fuzzing infinite mode, the test runner now receives a list of tests
from the build server. The fuzzer runs tests in batches of one second,
approximated in cycles by the previous batch's run speed. Tests finding
new inputs or with few runs are given a higher run chance. The baseline
run chance is based off the recency of the last find and the number of
pcs the test has hit.
2026-04-03 12:27:34 +02:00
Justus Klausecker ce3f254526 std.heap.ArenaAllocator: do not cmpxchg in hot path when it would be a noop
The cmpxchg is there to recover alignment padding that isn't needed (which
can only be determined after the fetch-and-add that reserves it as allocated
memory). As cmpxchg tends to be a very expensive operation, it is actually
faster to introduce an additional branch here that checks if the cmpxchg
would be a noop (because all of the reserved alignment padding was in fact
necessary) and skips it if that's the case.

This does not measurably regress performance if the arena is only accessed
by a single thread and yields slight performance benefits for multi-threaded
usage. If the arena is commonly used for unaligned allocations, the perf
benefits are quite significant.

Co-authored-by: Jacob Young <amazingjacob@gmail.com>
2026-04-02 23:00:26 +02:00
Andrew Kelley e9df86aed0 Merge pull request 'std.heap.ArenaAllocator: decrease fuzz test workload per run' (#31596) from justusk/zig:fuzz-arena-2 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31596
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:57:41 +02:00
Andrew Kelley 43d84420f3 Merge pull request 'std: add mem.absorbSentinel(), fix sentinel handling in Allocator interface' (#31611) from ifreund/zig:absorb-sent into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31611
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:55:21 +02:00
Andrew Kelley 3e0f55fcc7 Merge pull request 'add an ast smith' (#31635) from gooncreeper/zig:ast-smith into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31635
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:41:05 +02:00
johan0A 022c76fc89 std.Build.Module: fix dangling slice in dynamic linker arg 2026-04-02 15:19:14 +02:00
Hila Friedman 746dd51faf Simplify std.ArrayList.replaceRange and std.ArrayList.replaceRangeAssumeCapacity (#31710)
The implementations of `std.ArrayList.replaceRange` and `std.ArrayList.replaceRangeAssumeCapacity` were needlessly complicated, called `@memcpy` too many times, and left the structure in a semi-modified state in OOM conditions. This commit fixes that.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31710
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Hila Friedman <red.black.liquorice@gmail.com>
Co-committed-by: Hila Friedman <red.black.liquorice@gmail.com>
2026-04-02 15:11:24 +02:00
Jonathan Marler f4eecf8d7d handle EROFS in create/open file
I hit an unexpected errno 30 on macos attempting to call createFile on a
directory in PATH.  errno 30 is EROFS, this change propagates that error
as error.ReadOnlyFileSystem.
2026-04-02 15:05:31 +02:00
Andrew Kelley 617979ef26 std.Build.WebServer: use Io.concurrent rather than threads
allows the code to also work in evented mode
2026-04-01 02:54:25 -07:00
Andrew Kelley bd05d13d5f std: make file locking tests use io not threads
This will allow the tests to also run in single-threaded evented mode.
2026-04-01 02:54:25 -07:00
Brandon Black 1226bb9268 LinuxThreadImpl: be precise in tls.prepareArea arg
This isn't causing any functional problem today, but technically
`mapped[tls_offset..]` runs past the tls part of `mapped` and into
the `Instance` storage, and currently `prepareArea()` memsets its
entire argument to zero.  It is only the current layout and
initialization order of `mapped` that prevents this from being a
problem.  Being more precise here avoids future footguns if any of
that changes.
2026-03-31 14:48:03 -05:00
Brandon Black 614cd66e7e LinuxThreadImpl: clear tidptr during detached exit
Fixes: #31714
2026-03-31 14:47:44 -05:00
Brandon Black bb9f97e085 std.os.linux: add set_tid_address 2026-03-31 14:47:22 -05:00
Andrew Kelley 9b1eaad13f std.Build.Step.ConfigHeader: add addIdent function
for when you need to emit a bare identifier but from a string
2026-03-30 00:37:39 -07:00
Jacob Young 0db75c0116 std.Io.Threaded: fix dns queries on windows
by working around various bugs in `DnsQueryEx`.

Closes #31659
2026-03-30 09:33:04 +02:00
Frank Denis 42e33db9d0 Merge pull request 'crypto.base64: use "-" instead of "+" character in URL-safe mode' (#31709) from jedisct1/zig:urlsafe into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31709
2026-03-29 18:20:14 +02:00
Frank Denis dcb33abc2c crypto.base64: use "-" instead of "+" character in URL-safe mode
/ was turned into _, but + also needs to be turned into -
2026-03-29 09:33:22 +02:00
Matthew Lugg d28c5069b8 llvm: rework handling of globals
The main goal here is to make incremental compilation work a bit better.
I also slightly expanded some `std.zig.llvm.Builder` APIs so that we
don't need to pointlessly create new `Global`s whenever e.g. a function
turns into a variable or vice versa.

Also, lean into aliases for exports! If we just use aliases for every
export, everything becomes simpler. Besides, we can't just go around
renaming the globals of `Nav`s: the export could disappear on a future
update, in which case we'd have to somehow revert that change, which is
easier said than done.
2026-03-28 16:50:42 +00:00
Andrew Kelley b4e21ccb49 Merge pull request 'std.tar.extract: sanitize path traversal' (#31685) from tar into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31685
2026-03-27 15:00:29 +01:00
Andrew Kelley 2d3694ab42 Merge pull request 'std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos' (#31684) from resolve_beneath into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31684
2026-03-27 12:24:09 +01:00
GasInfinity 1f79a9e4e3 feat(Io.net): add allow_broadcast to BindOptions
* and implement it in `Threaded`, `Uring` and `Kqueue`
2026-03-27 09:43:57 +01:00
Andrew Kelley 9ad6843b20 std.tar.extract: sanitize path traversal
closes #31362
2026-03-27 01:27:38 -07:00
Andrew Kelley 79b5433da7 std.tar: rename pipeToFileSystem to extract 2026-03-27 01:27:26 -07:00
Andrew Kelley 2e4482cd14 std.Io.Dir: add resolve_beneath flag and implement for freebsd,macos 2026-03-27 01:23:04 -07:00
Andrew Kelley 6f467e436d std.Io: move File.CreateFlags to Dir.CreateFileOptions
for naming consistency.

same thing with File.OpenFlags -> Dir.OpenFileFlags
2026-03-27 01:23:04 -07:00
Andrew Kelley 0d25302d43 Package.Fetch: bump redirect buffer size
RFC 9110 says

> It is RECOMMENDED that all senders and recipients support, at a minimum,
> URIs with lengths of 8000 octets in protocol elements.

closes #30207
2026-03-27 08:42:02 +01:00
Jacob Young 49a258c0e0 std.Build.Step.Run: improve syscalls while running zig test executables
Previously, each message requires an unseekable error to be returned
from a syscall before proceeding.  Ideally, the code would just pass
around `*std.Io.Writer` instead of `std.Io.File` in the first place, but
even then, you could argue for saving a syscall with `writerStreaming`.
2026-03-27 03:28:50 +01:00
Alex Rønne Petersen f40eb50157 std.fs.test: disable '.' and '..' in Dir functions test on *-windows
https://codeberg.org/ziglang/zig/issues/31561
2026-03-27 02:24:23 +01:00
Alex Rønne Petersen 36b28050f4 std.fs.test: disable AtomicFile test on windows
https://codeberg.org/ziglang/zig/issues/31389
2026-03-27 02:24:21 +01:00
Alex Rønne Petersen c3d474bf6f Merge pull request 'link.MachO.Dylib: allow aarch64-macos to match arm64e-macos TBD entries' (#31673) from alexrp/zig:thanks-apple into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31673
2026-03-27 01:30:00 +01:00
Alex Rønne Petersen cef16b5130 std.Target: don't claim that OpenBSD requires libc
https://codeberg.org/ziglang/zig/issues/30982
2026-03-26 05:50:51 +01:00
Andrew Kelley abd131e336 zig cc: make --version use the full clang CLI lowering code path
because clang wants to parse the -target argument with clang -target
syntax.

closes #30178
2026-03-25 18:29:19 -07:00
Kendall Condon 0b52cac434 zig fmt: add missed maybe_spaces 2026-03-25 17:30:51 -04:00
Kendall Condon 09e523bd51 zig fmt: fix overindent tracking in sub-renders
This problem also affected determining if an expression became multiline
as that depends on if the line is overindented. As such,
`becomesMultilineExpr` has been replaced by `rendersMultiline` which
constructs a temporary writer which returns `error.WriteFailed` when
newlines are written. This new approach also has the advantage of being
more maintainable.
2026-03-25 17:30:51 -04:00
Kendall Condon 92915a42b5 zig fmt: do not reorder pointer casts with comments
This was especially bad as it could crash or duplicate them due to
them being moved around "zig fmt: on/off".

As a bonus this fixes a crash from reordering at the start of the file.
2026-03-25 17:30:51 -04:00
Kendall Condon ab237855b8 zig fmt: render asm colons with trailing comments
Previously, the comments would be lost with the colons.

This required a substantial rewrite of renderAsm to determine how many
colons should be rendered.
2026-03-25 17:30:51 -04:00
Kendall Condon c818a1e61f zig fmt: handle skip space for multiline strings 2026-03-25 17:30:51 -04:00
Kendall Condon ed3ca0f570 zig fmt: call ais.resetLine after "zig fmt: on" 2026-03-25 17:30:51 -04:00
Kendall Condon d70a9ea5d7 zig fmt: properly revert nested asm indentation 2026-03-25 17:30:51 -04:00
Kendall Condon 23db309043 zig fmt: use AstSmith in fuzz test 2026-03-25 17:30:51 -04:00
Kendall Condon 785fb1be11 fix several inconsistencies between parser and PEG
- PEG / Parser Changes

All the changes made here are to places where the PEG was more
permissive than the parser. Changes to the parser make it more
permissive and changes to the PEG make it more strict. When choosing
between these two options for discrepancies, I opted for the choice
that was more natural and increased code readability.

Changes to the Parser
* Tuple types can now be `inline` and `extern` (e.g. `extern struct`).
* Break labels are now only consumed if both the colon and identifier
  are present instead of failing if there is only a colon.
* Labeled blocks are no longer parsed in PrimaryExpr (so they are now
  allowed to have CurlySuffixExpr) as in the PEG.
* While expressions can now be grouped on the same line.
* Added distinction in error messages for "a multiline string literal"
  so places where only single string literals are allowed do not give
  "expected 'a string literal', found 'a string literal'".

Changes to the PEG
* Made it so extern functions cannot have a body
* Made it so ... can be only the last function argument
* Made it so many item pointers can't have bit alignment
* Made it so asm inputs / outputs can not be multiline string literals
* Added distinction between block-level statements and regular
  statements

-- Pointer Qualifier Order

The PEG allowed for duplicated qualifiers, which the parser did not.
The simplest fix for this was to make each be allowed zero or one times
which required giving them a order similar to how FnProto already
works. The chosen order is the same as used by zig fmt. The parser
still accepts them in any order similar to functions.

-- Backtracking

Made it so several places could not backtrack in the PEG. A common
pattern for this was (A / !A).

--- !ExprSuffix

Expressions ending with expressions now have !ExprSuffix after.
This change prevents expressions such as `if (a) T else U{}` being be
parsable as `(if (a) T else U){}`. It also stops some backtracking,
take for example:

`if (a) for (b) |c| d else |e| f`

It may seem at first that the else clause belongs to the `for`, however
it actually belongs to the `if` because for else-clauses cannot have a
payload. This is fixed by a new `KEYWORD_else / !KEYWORD_else`, however
this alone does not fix more complex cases such as:

`if (a) for (b) |c| d() else |e| f`

The PEG would first attempt to parse it as expected but fail due to the
new guard. It will then backtrack to

`if (a) (for (b) |c| d)() else |e| f`

which is surprising but avoids the new gaurd. So, !ExprSuffix is
required to disallow this type of backtracking.

--- !LabelableExpr

For identifiers, excluding labels is necessary despite ordered choice
due to pointer bit alignment. For example `*align(a : b: for (c) e) T`
could backtrack to `*align(a : b : (for (c) e)) T`.

--- !SinglePtrTypeStart

Prevents expressions like `break * break` which is parsed as
`break (*break)` backtracking to `(break) * (break)`

--- !BlockExpr

Prevents expressions like `test { {} = a; }` being backtracked to and
parsed as `test { ({} = a); }` (the parenthesis are just for
demonstration, that expression is not legal either)

--- !ExprStatement

In addition to splitting up block level statements, statements that are
also parsable as expressions are now part of ExprStatement to disallow
backtracking.
2026-03-25 17:29:56 -04:00
Kendall Condon 2aee0cd6b9 add an ast smith
This generates zig ASTs from `testing.Smith` and is based off the
langref's PEG.

The choice to not build the Ast while generating and instead parsing it
afterwards makes the smith more versatile by not being tied to a single
implementation at a cost of efficiency.

Additionally, a new function `boolWeighted` was added to `Smith` due to
its frequent use in `AstSmith`.
2026-03-25 17:27:18 -04:00