Commit Graph

14850 Commits

Author SHA1 Message Date
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 b36cfc6352 compiler-rt: work around LLVM not respecting -fno-builtin 2026-03-28 19:25:01 +00: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 b490412cd2 build runner: fail, not warn when insufficient memory
Users can proceed by telling the build system how much memory to assume
the system has. I have improved the failure message to communicate this.

Partially reverts 87f8f47ba5

Even if we wanted to unrevert this reverted commit, it's not sufficient
to merely downgrade the failure to a warning, because the main
scheduling logic will fail to schedule steps that have a max_rss
exceeding the detected system value, causing some steps to never get
executed, eventually tripping an assert. Such a change would need to
also override the max_rss value to be equal to the greatest value across
all steps.

closes #31510
2026-03-27 18:06:08 +01: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
Linus Groh f19be20912 libc: Update macOS headers to SDK 26.4 2026-03-26 19:25:56 +00: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
Justus Klausecker 5363a81a57 std.heap.FixedBufferAllocator: fix end_index memory ordering
This prevents a race between `alloc` and `free` where T1 receives memory
from `alloc` that is semantically about to be freed by T2 and still being
accessed, but the `free` is already visible to T1. Using acquire-release
here guarantees that any `free` is only published after all accesses to
the memory being freed have already happened.

Co-authored-by: Jacob Young <amazingjacob@gmail.com>
2026-03-25 11:48:45 +01:00
Justus Klausecker 3af5f81e11 std.heap.ArenaAllocator: fix end_index memory ordering
This prevents a race between `alloc` and `free` where T1 receives memory
from `alloc` that is semantically about to be freed by T2 and still being
accessed, but the `free` is already visible to T1. Using acquire-release
here guarantees that any `free` is only published after all accesses to
the memory being freed have already happened.

Co-authored-by: Jacob Young <amazingjacob@gmail.com>
2026-03-25 11:48:43 +01:00
Justus Klausecker 9bfe827ade Revert "std.heap.ArenaAllocator: Make resize and free check whether allocation is within current node more rigorously"
This reverts commit 589bcb2544.

The scenario presented in the reverted commit cannot actually happen.
Even if there are two contiguous arena nodes N1 and N2 and the `end_index`
of N1 points to somewhere in N2, a `resize` can never lead to an increase
of the `end_index` of N1 since it checks whether it's `<= size` first.
A `resize`/`free` *can* decrease `end_index`, but even if it is wrongly
assumed that some allocation that belongs to N2 actually belongs to N1
based on the `end_index` of N1, it can only ever be decreased to the start
of the buffer of N2. That's because a valid allocation of N2 logically
cannot be at any lower address than N2 itself. And any point still in N2
can never also be in N1, so there's no danger of overwriting any other
allocations of N1.
2026-03-25 11:20:21 +01:00
rpkak 8f6bad065e std.Thread.setName/getName: remove wrong error handling
std.posix.prctl already does error handling.
According to the man page PR_SET_NAME(2const), 0 is returned on success.
2026-03-25 08:10:25 +01:00
Jake Greenfield 4431ca28b8 fix Windows clock handling
Address two separate but related issues:
- Return value of `RtlQueryPerformanceFrequency` was used inconsistently; it
  returns a nonzero value to indicate success.
- `timeoutToWindowsInterval` wasn't converting absolute deadlines back to the
  Windows epoch before passing them to the system, which meant that values (in
  the Unix epoch) were always in the distant past, so sleeps would return
  immediately.

Fixes #31653
2026-03-24 21:33:27 -04:00
akhildevelops eec244c5a2 std.crypto.tls.Client: expose InitError (#31610)
Fixes: https://codeberg.org/ziglang/zig/issues/31581
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31610
Co-authored-by: akhildevelops <akhildevelops@noreply.codeberg.org>
Co-committed-by: akhildevelops <akhildevelops@noreply.codeberg.org>
2026-03-25 00:56:22 +01:00
Justus Klausecker 589bcb2544 std.heap.ArenaAllocator: Make resize and free check whether allocation is within current node more rigorously
This prevents the following scenario where an allocation is wrongly assumed
to be part of the current head node (`node0`):

```
| node0 - - - - | node1 - - - - - - - - - - - - |
          |   |         |   |           |
          |   |         |   end_index0  end_index1
          |   |         |   |
          alloc0        alloc1

free(alloc1):
    load node0
    buf0.ptr + end_index0 == alloc1.ptr + alloc1.len ? yes!
    end_index0 -= alloc1.len

| node0 - - - - | node1 - - - - - - - - - - - |
          | | |                         |
          | end_index0                  end_index1
          |   |
          alloc0
```

which could move `end_index0` *into* `alloc0` and make it possible for any
subsequent calls to `alloc` to overwrite its contents!
2026-03-25 00:54:44 +01:00
Alex Rønne Petersen b0ab55b8ea Merge pull request 'Add psp os' (#31609) from IridescentRose/zig:psp-os-target into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31609
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-03-25 00:51:01 +01:00
Alex Rønne Petersen 558a5c7913 std.c: audit some time types for non-Linux OSs
Some initial work towards https://codeberg.org/ziglang/zig/issues/31414.

Conclusion from this: Only x86-freebsd, x86-haiku, and x86-illumos remain time32
and are currently unfixable. I don't think the upstreams for any of these
targets actually care about them anymore (probably why they weren't migrated to
time64), so this is not a particularly big concern.

I split UTIME constants out from timespec because they were causing unreasonable
code duplication by being there.
2026-03-24 09:42:32 +01:00
Evgenii Orlov 0ee6a79da5 std.Io.net.HostName.netLookup: make canonical_name_buffer optional 2026-03-23 11:02:47 +01:00
Alex Rønne Petersen c7d69f0160 std.mem: delete illegal code in findSentinel()
I understand the temptation to exploit page size knowledge to make this function
faster, but I don't think this code can ever be compatible with any reasonable
set of pointer provenance/aliasing rules. At the very least, I don't believe it
is compatible with LLVM's.

closes https://github.com/ziglang/zig/issues/23184
2026-03-23 05:35:04 +01:00
Techatrix 029719cf47 std.Uri: reject invalid URI schemes according to RFC3986 2026-03-23 05:22:46 +01:00
Kendall Condon 1708da2c71 libfuzzer: fix SkipZigTest with new inputs
It is now ignored for inputs from the corpus to ensure the filesystem
and process corpus stay in sync. For other (nondeterministic) inputs the
input builder is now reset.
2026-03-23 05:19:04 +01:00
Frank Denis b2c2b4d063 Merge pull request 'crypto: correct aes-siv s2v' (#31623) from sinon/zig:fix-aes-siv into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31623
Reviewed-by: Frank Denis <jedisct1@noreply.codeberg.org>
2026-03-23 03:11:13 +01:00
rpkak 9857dabfea std.c.MFD: support linux 2026-03-22 18:06:00 +01:00
David Rubin 8efd539305 crypto: correct aes-siv s2v
The first issue is that when len(Sn) >= 128,
we perform Sn xor D instead of the Sn xorend D
that is specified in RFC 5297.

The second issue is that we truncate the Sn
if it is larger than 4096 bytes, which could
lead to collisions between inputs. We solve
this by absoring the Sn into the CMAC state
perform the last 16 bytes, xoring those 16
bytes with D as described in the first issue,
and then updating and squeezing the CMAC.
2026-03-22 07:21:41 -07:00
Jacob Young ccf8e223f4 std.Io.net: disable unix socket test due to presumed windows kernel bug
Tracked by #31499
2026-03-22 09:37:12 -04:00
Nathan Bourgeois c824ce954e misc: Add allegrex CPU & features, run tool, update semver 2026-03-21 19:39:04 -04:00
Alex Rønne Petersen cb7d2b0563 Revert "std.Progress: use cmpxchgStrong instead of cmpxchgWeak for locking/unlocking IPC"
This reverts commit b6f99a59a3.

https://codeberg.org/ziglang/zig/pulls/31608#issuecomment-11875362
2026-03-21 14:04:24 +01:00
Nathan Bourgeois 2037dba90f std.posix: Minimal set to build an Io on PSP 2026-03-21 06:34:45 -04:00
Nathan Bourgeois fdf19984b8 std.Target: add psp os 2026-03-21 02:56:24 -04:00
Justus Klausecker 1f78e34de0 std.Io.Threaded: make mutexLock() use cmpxchgStrong instead of cmpxchgWeak
As established in 048e38624e and d70bd0b37e, mutexes should use a strong
cmpxchg when attempting to lock to guarantee that they actually succeed
if they aren't locked yet.

Also deletes an unused near-duplicate of `mutexLock()`.
2026-03-21 03:00:50 +01:00
Justus Klausecker b6f99a59a3 std.Progress: use cmpxchgStrong instead of cmpxchgWeak for locking/unlocking IPC
The `cmpxchgWeak` in `setIpcFile` could lead to the IPC file not being set
even though there's still a slot available because one or more slots were
spuriously skipped.

The `cmpxcheWeak` in `serialize` could lead to an unused IPC slot not
being locked and used even though it could be.
2026-03-21 03:00:50 +01:00
Andrew Kelley e938344100 Merge pull request 'linux: fix handling of O_TMPFILE flag on filesystems that do not support it' (#31543) from eshom/zig:tmpfile-not-supported into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31543
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-21 00:04:10 +01:00