From 8773b632418adb23cfda847f69e971e90eb6d3a7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 31 Mar 2025 14:57:12 -0700 Subject: [PATCH] EventLoop: take DetachedClosure into account when allocating --- lib/std/Io/EventLoop.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/std/Io/EventLoop.zig b/lib/std/Io/EventLoop.zig index d03f339b52..d5b91db476 100644 --- a/lib/std/Io/EventLoop.zig +++ b/lib/std/Io/EventLoop.zig @@ -68,13 +68,13 @@ const Fiber = struct { const min_stack_size = 4 * 1024 * 1024; const max_context_align: Alignment = .@"16"; const max_context_size = max_context_align.forward(1024); + const max_closure_size: usize = @max(@sizeOf(AsyncClosure), @sizeOf(DetachedClosure)); + const max_closure_align: Alignment = .max(.of(AsyncClosure), .of(DetachedClosure)); const allocation_size = std.mem.alignForward( usize, - std.mem.alignForward( - usize, + max_closure_align.max(max_context_align).forward( max_result_align.forward(@sizeOf(Fiber)) + max_result_size + min_stack_size, - @max(@alignOf(AsyncClosure), max_context_align.toByteUnits()), - ) + @sizeOf(AsyncClosure) + max_context_size, + ) + max_closure_size + max_context_size, std.heap.page_size_max, );