镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit 2f38721

Browse files
committed
fix(test262): release eval probe storage (#525)
Free --eval source bytes on every Context path, deinitialize failure-detail storage, and render temporary success/error strings through the Context arena before copying output. Validation: successful and throwing --eval probes preserve exact output with no SafeAllocator leaks; conformance smoke 33/33 passed. Flips 0 test262 cases.
1 parent 0e2ed15 commit 2f38721

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎conformance/test262.zig‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ fn captureDetail(gpa: std.mem.Allocator, ctx: *js.Context, err: anyerror, d: *st
529529
return;
530530
}
531531
}
532-
const s = ex.toString(gpa) catch "<throw>";
532+
// The detail list owns its copy; render through the Context arena
533+
// so an object conversion cannot strand an ambiguously owned GPA
534+
// string after the diagnostic is appended.
535+
const s = ex.toString(ctx.arena()) catch "<throw>";
533536
d.appendSlice(gpa, s) catch {};
534537
return;
535538
}
@@ -557,15 +560,17 @@ fn harnessIncludeOverride(abs_path: []const u8, name: []const u8) ?[]const u8 {
557560
fn runEval(gpa: std.mem.Allocator, io: std.Io, path: []const u8) !void {
558561
const out = std.Io.File.stdout();
559562
const src = std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(max_test_source_bytes)) catch return;
563+
defer gpa.free(src);
560564
const ctx = js.Context.create(gpa) catch return;
561565
defer ctx.destroy();
562566
var buf: [4096]u8 = undefined;
563567
if (ctx.evaluate(src)) |v| {
564-
const s = v.toString(gpa) catch "?";
568+
const s = v.toString(ctx.arena()) catch "?";
565569
const line = std.fmt.bufPrint(&buf, "OK {s}\n", .{s}) catch "OK\n";
566570
out.writeStreamingAll(io, line) catch {};
567571
} else |err| {
568572
var d: std.ArrayListUnmanaged(u8) = .empty;
573+
defer d.deinit(gpa);
569574
captureDetail(gpa, ctx, err, &d);
570575
const line = std.fmt.bufPrint(&buf, "ERR {s}\n", .{d.items}) catch "ERR\n";
571576
out.writeStreamingAll(io, line) catch {};

0 commit comments

Comments
 (0)