Commit Graph

36917 Commits

Author SHA1 Message Date
Andrew Kelley f612d5ae96 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-27 15:33:46 -08:00
Andrew Kelley 46b5eb6ec3 std.Io.Threaded: detect 0 byte successful reads
according to ms docs this can happen with 0 byte writes to pipes.
2026-01-27 15:32:34 -08:00
Andrew Kelley 1e188d790a std.Io.Threaded: fix bad use of AlertableSyscall
The defer causes 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-27 15:32:34 -08:00
Andrew Kelley 15e73c70ab build.zig: bump max_rss for windows module tests
observed error: memory usage peaked at 0.62GB (620556288 bytes),
exceeding the declared upper bound of 0.60GB (603070054 bytes).
2026-01-27 15:32:34 -08:00
Andrew Kelley 27e6474508 test_runner: add a temporary debugging commit
to narrow in on the observed failure on Windows
2026-01-27 15:32:34 -08:00
Jacob Young 456e0492f2 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-27 15:32:34 -08:00
Andrew Kelley 041add45ad std.Io.Threaded: fix NtDelayExecution delay interval 2026-01-27 15:32:34 -08:00
Andrew Kelley 79be6b7ffe std.Io.Threaded: handle some more error codes from NtReadFile 2026-01-27 15:32:34 -08:00
Andrew Kelley e0d9c04e35 std.Io.Threaded: avoid extra fields of Thread
As mlugg pointed out those race when a thread finishes an operation just
after it is canceled and then that thread to picks up another task,
resulting in these fields being potentially overwritten.

This updates fileReadStreaming on Windows to handle being alerted, and
then manage its own cancelation of the file I/O.
2026-01-27 15:32:34 -08:00
Andrew Kelley c155ac50c2 std.Io.Threaded: don't pass null to NtDelayExecution
Windows returns ACCESS_VIOLATION if you do that.
2026-01-27 15:32:34 -08:00
Andrew Kelley 7ab41bec29 std.Io.Threaded: implement APC cancelation
specifically the call to NtCancelIoFileEx
2026-01-27 15:32:34 -08:00
Andrew Kelley e18ee3a93a std.Io.Threaded: introduce Thread.InterruptMethod
implements APC cancelation except for the actual call to NtCancelIoFileEx
2026-01-27 15:32:34 -08:00
Andrew Kelley 20c4211b6e std.Io.Threaded: add some temporary, choice panics 2026-01-27 15:32:34 -08:00
Andrew Kelley 693b2ffd5c std: back out the flags field of Io.File
For now, let us refrain from putting the sync mode into the Io.File
struct, and document that to do concurrent batch operations, any Windows
file handles must be in asynchronous mode. The consequences for
violating this requirement is neither illegal behavior, nor an error,
but that concurrency is lost. In other words, deadlock might occur. This
prevents the addition of flags field.

partial revert of 2faf14200f58ee72ec3a13e894d765f59e6483a9
2026-01-27 15:32:34 -08:00
Andrew Kelley de3a2c0ebb std.Io: give File a nonblocking bit on Windows
This tracks whether it is a file opened in synchronous mode, or
something that supports APC.

This will be needed in order to know whether concurrent batch operations
on the file should return error.ConcurrencyUnavailable, or use APC to
complete the batch.

This patch also switches to using NtCreateFile directly in
std.Io.Threaded for dirCreateFile, as well as NtReadFile for
fileReadStreaming, making it handle files opened in synchronous mode as
well as files opened in asynchronous mode.
2026-01-27 15:32:34 -08:00
Alex Rønne Petersen 0f51f663f0 musl: update some hexagon headers from the quic fork 2026-01-27 23:24:57 +01:00
just_some_entity 06cf86abeb Fix BootServices.locateHandleLen() (#30877)
Fixes https://codeberg.org/ziglang/zig/issues/30876

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30877
Reviewed-by: linus <mail@linusgroh.de>
Co-authored-by: just_some_entity <entity@jsentity.dev>
Co-committed-by: just_some_entity <entity@jsentity.dev>
2026-01-27 23:09:51 +01:00
Ryan Liptak 1655a666d5 windows_resources standalone test: Load a resource and check its data
Just a potential way to catch regressions and to ensure the resources actually make it into the binary correctly.
2026-01-27 20:48:59 +01:00
Ryan Liptak 29b7214027 Disentangle from error.CurrentWorkingDirectoryUnlinked
This error is actually only ever directly returned from `std.posix.getcwd` (and only on POSIX systems, so never on Windows). Its inclusion in almost all of the error sets its currently found in is a leftover from when `std.fs.path.resolve` called `std.process.getCwdAlloc` (https://github.com/ziglang/zig/issues/13613).
2026-01-27 20:48:25 +01:00
Andrew Kelley 3729a53eec Merge pull request 'libc: use common implementations for linux syscalls' (#30993) from GasInfinity/zig:libc-musl-syscalls into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30993
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-01-27 07:48:58 +01:00
Alex Rønne Petersen 5652288e5d zig fmt
oops
2026-01-27 07:05:14 +01:00
Alex Rønne Petersen f7df723a91 Merge branch 'prefer-io-futex' 2026-01-27 05:37:40 +01:00
Alex Rønne Petersen 2c7d3c8007 std.debug: use debug_io for the futex in waitForOtherThreadToFinishPanicking 2026-01-27 05:37:01 +01:00
Alex Rønne Petersen d4d210fb37 std.Build.WebServer: use Io futex operations instead of std.Thread.Futex 2026-01-27 05:37:01 +01:00
Robert Ancell 0af79e7b8c std.mem.readVarInt: Fix type name in doc comment (#31007)
Code used `ReturnType`, comment used `T` (which is what is used in similar functions).

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31007
Co-authored-by: Robert Ancell <robert.ancell@gmail.com>
Co-committed-by: Robert Ancell <robert.ancell@gmail.com>
2026-01-27 05:29:51 +01:00
Pablo Alessandro Santos Hugen 951ab1b18b std.Build.Step.Compile: pass target by pointer to isLibC*LibName 2026-01-27 05:29:04 +01:00
Alex Rønne Petersen 519f1eb361 musl: zero fp/lr registers in _start() and clone() on hexagon 2026-01-27 05:23:31 +01:00
Brian Orora 4e3fadd90e std.heap.DebugAllocator: fix account total_requested_bytes on resizeSmall 2026-01-27 00:09:48 +01:00
GasInfinity 73ed351022 fix(libzigc): export mincore 2026-01-27 00:06:18 +01:00
Carmen 5e9c484745 std.Io.Reader.takeStruct: dont assert buffer capacity is sizeOf(T) 2026-01-27 00:05:42 +01:00
Jay Petacat 97986184ca langref: Add table of largest integer types that can coerce to floats
Add vertical margin to the `.table-wrapper` class so that there's space
between the table and the test figures. It does not affect any of the
existing tables because the margin collapses with the adjacent `<p>`.
2026-01-26 23:52:30 +01:00
Andrew Kelley 1b235540c1 Revert "Io.Threaded: remove WSA_FLAG_OVERLAPPED from socket call"
The stated reason for this commit was cancelation didn't work. On
further review, we know why cancelation didn't work, and recent
enhancements on master branch make it easy to make it work.

Meanwhile, not using overlapped means that multiple threads cannot use
the same open socket handle. I also added line comments to explain the
choice in this revert commit.

This reverts commit fd3657bf8c.

closes #31011
reopens #30865
2026-01-26 14:16:28 -08:00
Andrew Kelley 5eb55ba866 Merge pull request 'compiler: use Io.MemoryMap' (#30961) from use-mmap into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30961
2026-01-26 22:58:01 +01:00
Alex Rønne Petersen 8d4b8ab6a5 Merge pull request 'glibc 2.43' (#31005) from alexrp/zig:glibc-2.43 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31005
2026-01-26 18:42:37 +01:00
jsentity b4c86c850d Fix std.uefi.protocol.DevicePath.next() and add utility function isEnd() (#30887)
Fix for https://codeberg.org/ziglang/zig/issues/30884 and https://codeberg.org/ziglang/zig/issues/30885

Co-authored-by: jsentity <jsentity@noreply.codeberg.org>
Co-committed-by: jsentity <jsentity@noreply.codeberg.org>
2026-01-26 11:41:22 +01:00
Alex Rønne Petersen ff8dbd010f libc: update glibc crt0 code to 2.43 2026-01-26 05:56:54 +01:00
Alex Rønne Petersen e4058f2c27 libc: update glibc abilists to 2.43 2026-01-26 05:56:54 +01:00
Alex Rønne Petersen 49afd7eee0 libc: update glibc headers to 2.43 2026-01-26 05:56:54 +01:00
Alex Rønne Petersen f6ed859cb0 std.zig.target: update glibc triples for loongarch64 targets 2026-01-26 05:56:53 +01:00
Michael Dusan f186809caf std: impl process.totalSystemMemory for netbsd 2026-01-25 13:03:22 -05:00
Frank Denis 8709f53d44 crypto.ff: allow seamless chaining regardless of representation (#30913)
Finite field elements can be in regular or Montgomery form, and
chaining different operations use to require manual and error-prone
conversions.

Now:

- `add`, `sub` and `mul` convert the second operand to match the
first operand's form
- `sq` and `pow` preserve the input's Montgomery form
- `toPrimitive` and `toBytes` return `UnexpectedRepresentation` if
the element is in Montgomery form, preventing incorrect serialization

This is fully backwards compatible and allows seamless chaining of
operations regardless of their representation.
2026-01-25 17:42:01 +01:00
Alex Rønne Petersen 99ec1ee353 ci: temporarily disable x86_64-netbsd while I investigate failures 2026-01-24 21:08:20 +01:00
GasInfinity 9cf34a8d81 feat(libzigc): move over some linux syscalls
* does not move all of them, only those which map almost 1:1
* also removes their musl implementation
2026-01-24 20:41:15 +01:00
GasInfinity b430cd62e4 feat(std.os.linux): add some missing syscalls 2026-01-24 20:41:15 +01:00
GasInfinity d5c3bf25dc feat(std.c): add _Exit 2026-01-24 20:41:15 +01:00
Andrew Kelley a2ea36a517 zig libc: modify errno helper to eliminate @intCast
The vast majority of libc functions return `c_int` for the return value,
when setting errno. This utility function is for those cases.

Other cases can hand-roll the logic, or additional helpers can be added.
2026-01-24 20:18:18 +01:00
Alex Rønne Petersen 9d63dfaa81 link.Lld: give better exit status information for the lld child process
It's not nice to just throw away useful information.
2026-01-24 18:30:55 +01:00
Alex Rønne Petersen cf48041b55 std.Thread.Condition: use pthread_cond_t impl when OS has no futex primitive
Same principle as #30835.
2026-01-24 16:44:55 +01:00
Lukas Lalinsky 5f950884a1 std.c: add IPPROTO_RAW for Darwin platforms
IPPROTO_RAW (255) was missing from the Darwin/macOS IPPROTO struct,
even though it is defined in system headers and supported by the platform.
This is a commonly used protocol for raw IP sockets.
2026-01-24 12:26:00 +01:00
Alex Rønne Petersen 1b544f447a Merge pull request 'enable thumb-windows-gnu module tests' (#30968) from alexrp/zig:windows-pic into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30968
2026-01-24 02:09:41 +01:00