@zigc/lib 0.17.0-dev.389 → 0.17.0-dev.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/build_runner.zig +3 -3
- package/compiler/test_runner.zig +24 -14
- package/fuzzer.zig +3 -3
- package/package.json +1 -1
- package/std/Target/Query.zig +1 -2
- package/std/Target.zig +0 -1
- package/std/Thread.zig +10 -0
- package/std/debug.zig +2 -0
- package/std/elf.zig +3 -0
- package/std/fmt/float.zig +2 -0
- package/std/heap/ArenaAllocator.zig +3 -5
- package/std/heap/SafeAllocator.zig +2180 -0
- package/std/heap.zig +16 -0
- package/std/mem/Allocator.zig +2 -0
- package/std/mem.zig +12 -6
- package/std/os/linux/tls.zig +11 -0
- package/std/os/linux/xtensa.zig +171 -0
- package/std/os/linux.zig +32 -0
- package/std/os.zig +0 -5
- package/std/pie.zig +21 -0
- package/std/start.zig +17 -8
- package/std/testing.zig +5 -13
|
@@ -26,9 +26,9 @@ pub const std_options: std.Options = .{
|
|
|
26
26
|
pub fn main(init: process.Init.Minimal) !void {
|
|
27
27
|
// The build runner is often short-lived, but thanks to `--watch` and `--webui`, that's not
|
|
28
28
|
// always the case. So, we do need a true gpa for some things.
|
|
29
|
-
var
|
|
30
|
-
defer _ =
|
|
31
|
-
const gpa =
|
|
29
|
+
var safe_gpa_state: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{});
|
|
30
|
+
defer _ = safe_gpa_state.deinit();
|
|
31
|
+
const gpa = safe_gpa_state.allocator();
|
|
32
32
|
|
|
33
33
|
var threaded: std.Io.Threaded = .init(gpa, .{
|
|
34
34
|
.environ = init.environ,
|
package/compiler/test_runner.zig
CHANGED
|
@@ -91,8 +91,8 @@ fn mainServer(init: std.process.Init.Minimal) !void {
|
|
|
91
91
|
return std.process.exit(0);
|
|
92
92
|
},
|
|
93
93
|
.query_test_metadata => {
|
|
94
|
-
testing.allocator_instance = .{};
|
|
95
|
-
defer if (testing.allocator_instance.deinit()
|
|
94
|
+
testing.allocator_instance = .init(std.heap.page_allocator, .{});
|
|
95
|
+
defer if (testing.allocator_instance.deinit() != 0) {
|
|
96
96
|
@panic("internal test runner memory leak");
|
|
97
97
|
};
|
|
98
98
|
|
|
@@ -123,7 +123,10 @@ fn mainServer(init: std.process.Init.Minimal) !void {
|
|
|
123
123
|
|
|
124
124
|
.run_test => {
|
|
125
125
|
testing.environ = init.environ;
|
|
126
|
-
testing.allocator_instance = .{
|
|
126
|
+
testing.allocator_instance = .init(std.heap.page_allocator, .{
|
|
127
|
+
.canary = 0xc3a701ba,
|
|
128
|
+
.check_write_after_free = true,
|
|
129
|
+
});
|
|
127
130
|
testing.io_instance = .init(testing.allocator, .{
|
|
128
131
|
.argv0 = .init(init.args),
|
|
129
132
|
.environ = init.environ,
|
|
@@ -150,8 +153,7 @@ fn mainServer(init: std.process.Init.Minimal) !void {
|
|
|
150
153
|
},
|
|
151
154
|
};
|
|
152
155
|
testing.io_instance.deinit();
|
|
153
|
-
const leak_count = testing.allocator_instance.
|
|
154
|
-
testing.allocator_instance.deinitWithoutLeakChecks();
|
|
156
|
+
const leak_count = testing.allocator_instance.deinit();
|
|
155
157
|
try server.serveTestResults(.{
|
|
156
158
|
.index = index,
|
|
157
159
|
.flags = .{
|
|
@@ -173,8 +175,8 @@ fn mainServer(init: std.process.Init.Minimal) !void {
|
|
|
173
175
|
// since they are not present.
|
|
174
176
|
if (!builtin.fuzz) unreachable;
|
|
175
177
|
|
|
176
|
-
var gpa_instance: std.heap.
|
|
177
|
-
defer if (gpa_instance.deinit()
|
|
178
|
+
var gpa_instance: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{});
|
|
179
|
+
defer if (gpa_instance.deinit() != 0) {
|
|
178
180
|
@panic("internal test runner memory leak");
|
|
179
181
|
};
|
|
180
182
|
const gpa = gpa_instance.allocator();
|
|
@@ -271,14 +273,17 @@ fn mainTerminal(init: std.process.Init.Minimal) void {
|
|
|
271
273
|
|
|
272
274
|
var leaks: usize = 0;
|
|
273
275
|
for (test_fn_list, 0..) |test_fn, i| {
|
|
274
|
-
testing.allocator_instance = .{
|
|
276
|
+
testing.allocator_instance = .init(std.heap.page_allocator, .{
|
|
277
|
+
.canary = 0xc3a701ba,
|
|
278
|
+
.check_write_after_free = true,
|
|
279
|
+
});
|
|
275
280
|
testing.io_instance = .init(testing.allocator, .{
|
|
276
281
|
.argv0 = .init(init.args),
|
|
277
282
|
.environ = init.environ,
|
|
278
283
|
});
|
|
279
284
|
defer {
|
|
280
285
|
testing.io_instance.deinit();
|
|
281
|
-
if (testing.allocator_instance.deinit()
|
|
286
|
+
if (testing.allocator_instance.deinit() != 0) leaks += 1;
|
|
282
287
|
}
|
|
283
288
|
testing.log_level = .warn;
|
|
284
289
|
testing.environ = init.environ;
|
|
@@ -430,8 +435,11 @@ var fuzz_runner: if (builtin.fuzz) struct {
|
|
|
430
435
|
error.WriteFailed => panic("failed to write to stdout: {t}", .{stdout_writer.err.?}),
|
|
431
436
|
};
|
|
432
437
|
|
|
433
|
-
testing.allocator_instance = .{
|
|
434
|
-
|
|
438
|
+
testing.allocator_instance = .init(std.heap.page_allocator, .{
|
|
439
|
+
.canary = 0xc3a701ba,
|
|
440
|
+
.check_write_after_free = true,
|
|
441
|
+
});
|
|
442
|
+
defer if (testing.allocator_instance.deinit() != 0) std.process.exit(1);
|
|
435
443
|
is_fuzz_test = false;
|
|
436
444
|
|
|
437
445
|
builtin.test_functions[fuzz_runner.indexes[i]].func() catch |err| switch (err) {
|
|
@@ -554,8 +562,11 @@ pub fn fuzz(
|
|
|
554
562
|
|
|
555
563
|
fn test_one() callconv(.c) bool {
|
|
556
564
|
@disableInstrumentation();
|
|
557
|
-
testing.allocator_instance = .{
|
|
558
|
-
|
|
565
|
+
testing.allocator_instance = .init(std.heap.page_allocator, .{
|
|
566
|
+
.canary = 0xcacce5e0,
|
|
567
|
+
.check_write_after_free = true,
|
|
568
|
+
});
|
|
569
|
+
defer if (testing.allocator_instance.deinit() != 0) std.process.exit(1);
|
|
559
570
|
log_err_count = 0;
|
|
560
571
|
testOne(ctx, @constCast(&testing.Smith{ .in = null })) catch |err| switch (err) {
|
|
561
572
|
error.SkipZigTest => return true,
|
|
@@ -582,7 +593,6 @@ pub fn fuzz(
|
|
|
582
593
|
if (builtin.fuzz) {
|
|
583
594
|
// Preserve the calling test's allocator state
|
|
584
595
|
const prev_allocator_state = testing.allocator_instance;
|
|
585
|
-
testing.allocator_instance = .{};
|
|
586
596
|
defer testing.allocator_instance = prev_allocator_state;
|
|
587
597
|
|
|
588
598
|
global.ctx = context;
|
package/fuzzer.zig
CHANGED
|
@@ -39,10 +39,10 @@ fn logOverride(
|
|
|
39
39
|
fw.interface.flush() catch panic("failed to write to fuzzer log: {t}", .{fw.err.?});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var safe_allocator: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{});
|
|
43
43
|
const gpa = switch (builtin.mode) {
|
|
44
|
-
.Debug =>
|
|
45
|
-
.ReleaseFast, .ReleaseSmall
|
|
44
|
+
.Debug, .ReleaseSafe => safe_allocator.allocator(),
|
|
45
|
+
.ReleaseFast, .ReleaseSmall => std.heap.smp_allocator,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// Seperate from `exec` to allow initialization before `exec` is.
|
package/package.json
CHANGED
package/std/Target/Query.zig
CHANGED
|
@@ -533,9 +533,8 @@ pub fn serializeCpuAlloc(q: Query, ally: Allocator) Allocator.Error![]u8 {
|
|
|
533
533
|
return buffer.toOwnedSlice();
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
+
/// Deprecated; use `zigTriple` instead. Will be removed in 0.18.0.
|
|
536
537
|
pub fn allocDescription(self: Query, allocator: Allocator) ![]u8 {
|
|
537
|
-
// TODO is there anything else worthy of the description that is not
|
|
538
|
-
// already captured in the triple?
|
|
539
538
|
return self.zigTriple(allocator);
|
|
540
539
|
}
|
|
541
540
|
|
package/std/Target.zig
CHANGED
package/std/Thread.zig
CHANGED
|
@@ -1411,6 +1411,16 @@ const LinuxThreadImpl = struct {
|
|
|
1411
1411
|
: [ptr] "{r4}" (@intFromPtr(self.mapped.ptr)),
|
|
1412
1412
|
[len] "{r5}" (self.mapped.len),
|
|
1413
1413
|
: .{ .memory = true }),
|
|
1414
|
+
.xtensa, .xtensaeb => asm volatile (
|
|
1415
|
+
\\ movi a2, 81 // SYS_munmap
|
|
1416
|
+
\\ syscall
|
|
1417
|
+
\\ movi a6, 0
|
|
1418
|
+
\\ movi a2, 118 // SYS_exit
|
|
1419
|
+
\\ syscall
|
|
1420
|
+
:
|
|
1421
|
+
: [ptr] "{a6}" (@intFromPtr(self.mapped.ptr)),
|
|
1422
|
+
[len] "{a3}" (self.mapped.len),
|
|
1423
|
+
: .{ .memory = true }),
|
|
1414
1424
|
else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)),
|
|
1415
1425
|
}
|
|
1416
1426
|
unreachable;
|
package/std/debug.zig
CHANGED
package/std/elf.zig
CHANGED
|
@@ -224,6 +224,9 @@ pub const DT_PPC64_NUM = 4;
|
|
|
224
224
|
pub const DT_IA_64_PLT_RESERVE = (DT_LOPROC + 0);
|
|
225
225
|
pub const DT_IA_64_NUM = 1;
|
|
226
226
|
|
|
227
|
+
pub const DT_XTENSA_GOT_LOC_OFF = 0x70000000;
|
|
228
|
+
pub const DT_XTENSA_GOT_LOC_SZ = 0x70000001;
|
|
229
|
+
|
|
227
230
|
pub const DT_NIOS2_GP = 0x70000002;
|
|
228
231
|
|
|
229
232
|
pub const DF_ORIGIN = 0x00000001;
|
package/std/fmt/float.zig
CHANGED
|
@@ -671,12 +671,10 @@ test "reset while retaining a buffer" {
|
|
|
671
671
|
|
|
672
672
|
// Create two internal buffers
|
|
673
673
|
_ = try a.alloc(u8, 1);
|
|
674
|
-
_ = try a.alloc(u8, 1000);
|
|
675
|
-
|
|
676
674
|
try std.testing.expect(arena_allocator.state.used_list != null);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
675
|
+
while (arena_allocator.state.used_list.?.next == null) {
|
|
676
|
+
_ = try a.alloc(u8, 1000);
|
|
677
|
+
}
|
|
680
678
|
|
|
681
679
|
// This retains the first allocated buffer
|
|
682
680
|
try std.testing.expect(arena_allocator.reset(.{ .retain_with_limit = 2 }));
|