7370 Commits

Author SHA1 Message Date
Evin Yulo
854f26ad8a fix typo in std.Uri 2023-06-13 10:58:11 -07:00
bfredl
4f914c8414 bpf: expose "syscall" program type and F_SLEEPABLE flag 2023-06-13 10:57:51 -07:00
dweiller
28eed1f7b3 std.mem.ValidationAllocator: forward free() calls
Failing to forward free calls to the underlying allocator makes
`ValidationAllocator` unusable for testing allocators while checking for
leaks. This change allows allocators that wrap `std.testing.allocator`
to be tested with `std.heap.testAllocator()` in test decls without
reporting erroneous leaks.
2023-06-13 10:57:11 -07:00
Andrew Kelley
8cf72cdfb1
Merge pull request #15985 from erikarvstedt/fix-arena-alloc
arena_allocator/reset: fix use after free, fix buffer overrun
2023-06-13 10:52:41 -07:00
Eric Joldasov
d884d7050e
all: replace comptime try with try comptime
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Eric Joldasov
6078781ae5
std.Build.Step.Compile: remove addSystemIncludeDir, addIncludeDir, addLibPath, and addFrameworkDir (deprecated in 0.10)
Followup to d3d24874c91054a70c706fed47278c81c9ce890a.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Eric Joldasov
4936453d56
std.builtin: remove TypeInfo and Type.FnArg (deprecated in 0.10)
Followup to d3d24874c91054a70c706fed47278c81c9ce890a.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Eric Joldasov
4d5fb62a82
std.crypto.sign.Ed25519: remove sign, verify, key_blinding.sign, and
`key_blinding.unblindPublicKey` (deprecated in 0.10)

Followup to 9c0d975a099387cd2b47e527892e71ae1601eaf4.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Eric Joldasov
f7dddd4c81
std.debug: remove warn (deprecated in 0.9)
Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Eric Joldasov
ee821b2d7f
std.fmt: remove e, E, z, and Z specifiers (deprecated in 0.8)
Followup to cd7c870bd81391dd97c5c75eb3910382ba7280a1.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:56 +06:00
Eric Joldasov
53fc991abd
std.fmt.formatValue: remove B and Bi specifiers (deprecated in 0.8)
Followup to 72664df4911f5d5bddead48acde6275f1d5f2a5e.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Eric Joldasov
c46e5eb3e1
std.fifo.LinearFifo: remove ensureCapacity (deprecated in 0.9)
Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Eric Joldasov
b0ad1c86da
std.io: remove FindByteOutStream and findByteOutStream (deprecated in
0.9)

Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Eric Joldasov
e92dab14f9
std.meta: remove TagType (deprecated in 0.9)
Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Eric Joldasov
d04a262a3d
std.math: hard deprecate obsolete constants (soft deprecated in 0.10)
Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Eric Joldasov
eb4439f1e4
std.meta: remove Vector (deprecated in 0.10)
Followup to d42d31f72f38165f70c2850e9cc63da44b3b470c.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:08 +06:00
Erik Arvstedt
89bd29a905 arena_allocator/reset: avoid zero-capacity allocations
1. When the arena is already empty, resetting with `retain_capacity` no longer
   results in allocating a buffer with zero capacity.
   This behavior was previously intended by the `(current_capacity == 0)` check,
   but wasn't correctly implemented.

2. Resetting with `.{ .retain_with_limit = 0 }` is now equivalent to
   `free_all` and a new buffer with zero capacity is no longer created.
   This is a useful side-effect of the above fixes.
2023-06-13 09:48:51 +02:00
Erik Arvstedt
5d3c8f4913 arena_allocator/reset: fix use after free
Previously, when the last buffer in `buffer_list` was retained after
deleting all other buffers, `buffer_list` wasn't updated and pointed
to a deleted buffer.
2023-06-13 09:48:51 +02:00
Erik Arvstedt
41430a366f arena_allocator/reset: fix buffer overrun
Previously, the buffer reserved with `retain_with_limit` was missing
space for the `BufNode`.

When the user-provided a limit that was smaller than `@sizeOf(BufNode)`,
`reset` would store a new `BufNode` in an allocation smaller than
`BufNode`, leading to a buffer overrun.
2023-06-13 09:46:16 +02:00
mlugg
52e7934a21 std.dwarf: fix findCompileUnit when ranges offset is given by const 2023-06-12 14:22:45 -07:00
mlugg
9e61ba19e9 std.crypto.tls.Client: fix @memcpy crash in limitedOverlapCopy
Resolves: #15928
2023-06-12 14:22:09 -07:00
Andrew Kelley
ab86b20248 std.hash: improve small-key hashing in Wyhash
Instead of carrying an optimized version of wyhash in the compiler for
small keys, put it into the std lib where it belongs.

...except it does not match the official test cases. This will need to
be fixed before merging into master. This is an extremely
contributor-friendly task.

Related issue: #15916
2023-06-10 20:51:09 -07:00
Jacob Young
04e66e6b4d InternPool: add optional coercion 2023-06-10 20:47:59 -07:00
Andrew Kelley
34dae73005 std.hash: auto hash signed ints as bitcasts of unsigned ints 2023-06-10 20:47:58 -07:00
Jacob Young
dc18739a73 process: add more missing const 2023-06-10 20:47:58 -07:00
Jacob Young
cab79b0877 lib: add const to avoid regression
Not sure if this was meant to be legal or not, but either way this code
should have been using const anyway.
2023-06-10 20:47:58 -07:00
Jacob Young
26fac15f48 math.big.int: fix ctz of zero 2023-06-10 20:47:57 -07:00
Andrew Kelley
c7d65fa368 std.hash: add xxhash to benchmark and fix its API 2023-06-10 20:47:57 -07:00
Jacob Young
a803e9cf48 Sema: fix vector comparison and interning of -0 2023-06-10 20:47:57 -07:00
Jacob Young
6e0de1d116 InternPool: port most of value tags 2023-06-10 20:47:54 -07:00
Andrew Kelley
1b64eed107 remove the kludges from std.builtin
I added these in an earlier commit in this branch. This commit removes
them before the branch is merged.
2023-06-10 20:47:54 -07:00
Andrew Kelley
17882162b3 stage2: move function types to InternPool 2023-06-10 20:47:53 -07:00
Andrew Kelley
88dbd62bcb stage2: move enum tag values into the InternPool
I'm seeing a new assertion trip: the call to `enumTagFieldIndex` in the
implementation of `@Type` is attempting to query the field index of an
union's enum tag, but the type of the enum tag value provided is not the
same as the union's tag type. Most likely this is a problem with type
coercion, since values are now typed.

Another problem is that I added some hacks in std.builtin because I
didn't see any convenient way to access them from Sema. That should
definitely be cleaned up before merging this branch.
2023-06-10 20:46:17 -07:00
Andrew Kelley
1c7095cb7d add std.hash.uint32
This is handy if you have a u32 and want a u32 and don't want to take a
detour through many layers of abstraction elsewhere in the std.hash
namespace.
Copied from https://nullprogram.com/blog/2018/07/31/
2023-06-10 20:42:30 -07:00
Andrew Kelley
70a4b76aca std.builtin.AddressSpace: allocate one more bit to this enum 2023-06-10 20:42:28 -07:00
Andrew Kelley
75cf06c187 std.mem.alignForwardGeneric: manually inline the assertions
This matches more directly the documentation comments, and makes it more
obvious what went wrong when an assertion fails.
2023-06-10 20:42:28 -07:00
Andrew Kelley
cac60a05a7 std.builtin: give some enums integer types 2023-06-10 20:40:03 -07:00
Jacob G-W
c842deea75 os/plan9: fix order of register setting in syscall1
We need to set rbp last because the arguments are stored on the
stack. If we clobber rbp first, then we will get a segfault when
trying to access the function arguments.

I believe I had already done this with the other syscall* functions,
but not with syscall1, so this allows single argument syscalls like
close to work.
2023-06-10 11:36:32 +03:00
Veikka Tuominen
2094d98694
Merge pull request #15980 from squeek502/walker-fixes
A few `IterableDir.Walker`/`Iterator` fixes
2023-06-10 05:09:34 +03:00
sentientwaffle
f04e65bc09 std.hash_map: fetchRemove increment available
To avoid leaking slots, `fetchRemove` must increment `available` (when the "fetch" succeeds).

Without the `available += 1`, the added test `"std.hash_map repeat fetchRemove"` fails with

    run test std-x86-linux-none-Debug: error: thread 432734 panic: integer overflow
    .../zig/lib/std/hash_map.zig:1365:28: 0x6471d5 in getOrPutAssumeCapacityAdapted__anon_47495 (test)
            self.available -= 1;
                           ^
    .../zig/lib/std/hash_map.zig:1308:62: 0x616950 in getOrPutAssumeCapacityContext (test)
            const result = self.getOrPutAssumeCapacityAdapted(key, ctx);
                                                             ^

Alternatively, `fetchRemove` could call `removeByIndex`, though that would entail calling `header()` twice instead of once.
2023-06-10 02:24:35 +03:00
Ryan Liptak
af835111fa Allow recovering from Walker.next errors without continually hitting the same error
Before this commit, if Walker.next errored with e.g. `error.AccessDenied` and the caller did something like `while (true) { walker.next() catch continue; }`, then the directory that errored with AccessDenied would be continually iterated in each `next` call and error every time with AccessDenied.

After this commit, the directory that errored will be popped off the stack before the error is returned, meaning that in the subsequent `next` call, it won't be retried and the Walker will continue with whatever directories remain on its stack.

For a real example, before this commit, walking `/proc/` on my system would infinitely loop due to repeated AccessDenied errors on the same directory. After this commit, I am able to walk `/proc/` on my system fully (skipping over any directories that are unable to be iterated).
2023-06-08 02:16:15 -07:00
Ryan Liptak
7555085e63 Directory iteration: handle EACCES returned from getdents64
This can occur for directories that the user does not have the necessary permissions to be able to iterate.
2023-06-08 02:16:15 -07:00
Ryan Liptak
2f188290e2 Use iterateAssumeFirstIteration in Walker.next to avoid unnecessary lseek calls
Since we are opening each directory for iteration, we know that we don't need to reset the cursor's directory before iterating. Using `iterateAssumeFirstIteration` skips the cursor resetting which eliminates an `lseek` syscall for every directory opened on non-Windows platforms.

This doesn't seem to actually matter much for performance (1.01 ± 0.02 times faster when walking /home/ on my system) but avoiding unnecessary syscalls is always nice anyway.
2023-06-08 02:16:15 -07:00
Marc Tiehuis
00ff653576
reimplement wyhash v4.1 (#15969) 2023-06-07 19:27:17 -07:00
Josh Wolfe
cb7040154e
std: fix parseInt for single-digit signed minInt (#15966) 2023-06-07 10:34:25 -04:00
Frank Denis
9ee0a706da
crypto.bcrypt: allow very large passwords to be pre-hashed (#15955)
crypto.bcrypt: allow very large passwords to be pre-hashed

bcrypt has a slightly annoying limitation: passwords are limited
to 72 characters. In the original implementation, additional characters
are silently ignored.

When they care, applications adopt different strategies to work around
this, in incompatible ways.

Ideally, large passwords should be pre-hashed using a hash function that
hinders GPU attackers, and the hashed function should not be deterministic
in order to defeat shucking attacks.

This change improves the developer experience by adding a very explicit
`silently_truncate_password` option, that can be set to `false` in
order to do that automatically, and consistently across Zig applications.

By default, passwords are still truncated, so this is not a breaking
change.

Add some inline documentation for our beloved autodoc by the way.
2023-06-06 09:08:57 +02:00
Andrew Kelley
629f0d23b5
Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
dweiller
3add9d8257 std.c: fix return type of recv/recvfrom on windows
Windows defines `recv` and `recvfrom` to return a value of type `int`,
rather than a pointer-sized signed integer, and so should use `c_int`
rather than `isize` for their return types.
2023-06-03 13:45:52 -07:00
xEgoist
ff57a264ad
Build: fix producesPdbFile logic (#15756)
Fixes bug causing ReleaseSmall to fail on Windows.

Due to the change in default behavior of ReleaseSmall, debug info are
stripped by default. However because `Compile.create` still defaults to
null, `producesPdbFile` will report true for
`lib/std/Build/Step/InstallArtifact.zig` causing it to fail on copying a
file that does not exist. This commit change the default of strip
depending on `optimize`.
2023-06-03 16:45:08 -04:00
Eric Joldasov
5c6f111379 std.io.reader.Reader: add streamUntilDelimiter
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-03 13:38:23 -07:00