3
7
Fork
You've already forked oci
2

Allocation error in create_manifest.zig #3

Open
opened 2025年12月13日 19:03:18 +01:00 by jeffective · 1 comment

Having a hard time reproducing this, but something to watch out for, not sure why it would happen, we are using arena...

jeff@jeff-debian:~/repos/oci$ time zig build create-manifest
anyzig: .minimum_zig_version '0.16.0-dev.1484+d0ba6642b' pulled from '/home/jeff/repos/oci/build.zig.zon'
anyzig: appdata '/home/jeff/.local/share/anyzig'
anyzig: zig '0.16.0-dev.1484+d0ba6642b' already exists at '/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB'
create-manifest
└─ install generated to config.json
 └─ run exe create_manifest (manifest.json) stderr
error(gpa): Allocation size 1639 bytes does not match free size 1482. Allocation: 
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/heap/arena_allocator.zig:213:43: 0x1131d18 in alloc (std.zig)
 cur_node = self.createNode(cur_buf.len, n + ptr_align) orelse return null;
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:142:26: 0x10d7072 in rawAlloc (std.zig)
 return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:282:40: 0x10ba2d5 in allocWithSizeAndAlignment__anon_14850 (std.zig)
 return self.allocBytesWithAlignment(alignment, byte_count, return_address);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:270:89: 0x11c2bdc in allocAdvancedWithRetAddr (std.zig)
 const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address));
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/array_list.zig:438:67: 0x11b17c5 in ensureTotalCapacityPrecise (std.zig)
 const new_memory = try self.allocator.alignedAlloc(T, alignment, new_capacity);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/array_list.zig:414:51: 0x11948f8 in ensureTotalCapacity (std.zig)
 return self.ensureTotalCapacityPrecise(better_capacity);
 ^
 Free: 
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:142:26: 0x11fd427 in rawAlloc (std.zig)
 return a.vtable.alloc(a.ptr, len, alignment, ret_addr);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2679:42: 0x11fd103 in ensureTotalCapacity (std.zig)
 return ensureTotalCapacityPrecise(a, better_capacity);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2672:35: 0x11fc6be in ensureUnusedCapacity (std.zig)
 return ensureTotalCapacity(a, new_capacity);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2760:35: 0x11fb435 in drain (std.zig)
 a.ensureUnusedCapacity(bytes.len + splat_len + 1) catch return error.WriteFailed;
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:728:37: 0x109846e in writeByte (std.zig)
 const n = try w.vtable.drain(w, &.{&.{byte}}, 1);
 ^
/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:1876:24: 0x1168eb5 in printHex (std.zig)
 try w.writeByte(charset[c & 15]);
 ^
failed command: ./.zig-cache/o/54b433d2939d2e5e4e7cd2729da79871/create_manifest /home/jeff/repos/oci/.zig-cache/o/cfb3ef82aa6757b2b4bc4f5aaacaaa1b/manifest.json /home/jeff/repos/oci/.zig-cache/o/cfb3ef82aa6757b2b4bc4f5aaacaaa1b/config.json --layer=./.zig-cache/o/d1858801c4b535c5f5139bdcf235b7c2/blob.tar --layer=./.zig-cache/o/ec8f5c79bf4348b4b96a1f64015c3485/blob.tar.gz
real	0m2.229s
user	0m3.432s
sys	0m1.107s
Having a hard time reproducing this, but something to watch out for, not sure why it would happen, we are using arena... ``` jeff@jeff-debian:~/repos/oci$ time zig build create-manifest anyzig: .minimum_zig_version '0.16.0-dev.1484+d0ba6642b' pulled from '/home/jeff/repos/oci/build.zig.zon' anyzig: appdata '/home/jeff/.local/share/anyzig' anyzig: zig '0.16.0-dev.1484+d0ba6642b' already exists at '/home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB' create-manifest └─ install generated to config.json └─ run exe create_manifest (manifest.json) stderr error(gpa): Allocation size 1639 bytes does not match free size 1482. Allocation: /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/heap/arena_allocator.zig:213:43: 0x1131d18 in alloc (std.zig) cur_node = self.createNode(cur_buf.len, n + ptr_align) orelse return null; ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:142:26: 0x10d7072 in rawAlloc (std.zig) return a.vtable.alloc(a.ptr, len, alignment, ret_addr); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:282:40: 0x10ba2d5 in allocWithSizeAndAlignment__anon_14850 (std.zig) return self.allocBytesWithAlignment(alignment, byte_count, return_address); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:270:89: 0x11c2bdc in allocAdvancedWithRetAddr (std.zig) const ptr: [*]align(a.toByteUnits()) T = @ptrCast(try self.allocWithSizeAndAlignment(@sizeOf(T), a, n, return_address)); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/array_list.zig:438:67: 0x11b17c5 in ensureTotalCapacityPrecise (std.zig) const new_memory = try self.allocator.alignedAlloc(T, alignment, new_capacity); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/array_list.zig:414:51: 0x11948f8 in ensureTotalCapacity (std.zig) return self.ensureTotalCapacityPrecise(better_capacity); ^ Free: /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/mem/Allocator.zig:142:26: 0x11fd427 in rawAlloc (std.zig) return a.vtable.alloc(a.ptr, len, alignment, ret_addr); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2679:42: 0x11fd103 in ensureTotalCapacity (std.zig) return ensureTotalCapacityPrecise(a, better_capacity); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2672:35: 0x11fc6be in ensureUnusedCapacity (std.zig) return ensureTotalCapacity(a, new_capacity); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:2760:35: 0x11fb435 in drain (std.zig) a.ensureUnusedCapacity(bytes.len + splat_len + 1) catch return error.WriteFailed; ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:728:37: 0x109846e in writeByte (std.zig) const n = try w.vtable.drain(w, &.{&.{byte}}, 1); ^ /home/jeff/.cache/zig/p/N-V-__8AAMMAzhS44i3gROdtiKVCevpN_PbdgJBDAczz0KtB/lib/std/Io/Writer.zig:1876:24: 0x1168eb5 in printHex (std.zig) try w.writeByte(charset[c & 15]); ^ failed command: ./.zig-cache/o/54b433d2939d2e5e4e7cd2729da79871/create_manifest /home/jeff/repos/oci/.zig-cache/o/cfb3ef82aa6757b2b4bc4f5aaacaaa1b/manifest.json /home/jeff/repos/oci/.zig-cache/o/cfb3ef82aa6757b2b4bc4f5aaacaaa1b/config.json --layer=./.zig-cache/o/d1858801c4b535c5f5139bdcf235b7c2/blob.tar --layer=./.zig-cache/o/ec8f5c79bf4348b4b96a1f64015c3485/blob.tar.gz real 0m2.229s user 0m3.432s sys 0m1.107s ```
Collaborator
Copy link

yeah i got the same once now too...but its weird, like a bug with arena allocator and threading async io maybe...

yeah i got the same once now too...but its weird, like a bug with arena allocator and threading async io maybe...
Sign in to join this conversation.
No Branch/Tag specified
main
zig-0.17.X
feature/pull-image
feature/output-oci-dir
feature/hash-final-manifest
feature/parse-archive
compression-levels-enum
compression-levels
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jeffective/oci#3
Reference in a new issue
jeffective/oci
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?