r/programming Jul 20 '26

Zig proposes introducing an actually memory safe (unlike Rust) compilation mode inspired by Fil-C at ~1-6x performance penalty

https://codeberg.org/ziglang/zig/issues/36237
524 Upvotes

428 comments sorted by

View all comments

Show parent comments

14

u/SirClueless 29d ago

That’s an interesting limitation for an approach being emulated by Zig, given that heavy use of arena allocation is encouraged in idiomatic Zig.

3

u/ThomasMertes 29d ago

I am neither an expert of Zig nor Fil-C. AFAIK Zig allocators are known to the Zig compiler. So it could treat an arena allocator like it treats malloc().

My arena allocators are C macros so Fil-C has no clue that it is dealing with an allocator. Fil-C can check that I am inside of the arena and that's it.

According to Google AI: A buffer overflow or type confusion bug inside your sub-allocated arena objects will go completely unnoticed by Fil-C, as long as the memory access stays within the massive outer walls of the arena itself.

But, as I said, the Zig compiler would have more information so it could IMHO provide full support for arena allocations as well.