Use apge allocator again after it was fixed

This commit is contained in:
Alexandros Naskos 2020-06-29 02:03:51 +03:00
parent 0102963433
commit 6953ff95eb
2 changed files with 7 additions and 14 deletions

View File

@ -138,20 +138,16 @@ fn loadPackages(context: LoadPackagesContext) !void {
try std.fs.copyFileAbsolute(build_runner_path, target_path, .{}); try std.fs.copyFileAbsolute(build_runner_path, target_path, .{});
defer std.fs.deleteFileAbsolute(target_path) catch {}; defer std.fs.deleteFileAbsolute(target_path) catch {};
// TODO Using the page allocator directly here causes a segfault
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
const zig_run_result = try std.ChildProcess.exec(.{ const zig_run_result = try std.ChildProcess.exec(.{
.allocator = &arena.allocator, .allocator = allocator,
.argv = &[_][]const u8{ zig_exe_path, "run", "build_runner.zig" }, .argv = &[_][]const u8{ zig_exe_path, "run", "build_runner.zig" },
.cwd = directory_path, .cwd = directory_path,
}); });
// TODO Add those back in when we stop using the arena defer {
// defer { allocator.free(zig_run_result.stdout);
// allocator.free(zig_run_result.stdout); allocator.free(zig_run_result.stderr);
// allocator.free(zig_run_result.stderr); }
// }
switch (zig_run_result.term) { switch (zig_run_result.term) {
.Exited => |exit_code| { .Exited => |exit_code| {

View File

@ -1349,11 +1349,8 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config, ke
process.stdin.?.close(); process.stdin.?.close();
process.stdin = null; process.stdin = null;
// TODO readAllAlloc degfaults with the page allocator const stdout_bytes = try process.stdout.?.reader().readAllAlloc(allocator, std.math.maxInt(usize));
var arena = std.heap.ArenaAllocator.init(allocator); defer allocator.free(stdout_bytes);
defer arena.deinit();
const stdout_bytes = try process.stdout.?.reader().readAllAlloc(&arena.allocator, std.math.maxInt(usize));
// defer allocator.free(stdout_bytes);
switch (try process.wait()) { switch (try process.wait()) {
.Exited => |code| if (code == 0) { .Exited => |code| if (code == 0) {