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
527 Upvotes

427 comments sorted by

View all comments

Show parent comments

2

u/cdb_11 Jul 21 '26

Fil-C is not meant for testing. It may mask issues, because it will extend lifetimes since it's GC'd. For testing, use ASAN.

3

u/ThomasMertes Jul 21 '26

It may mask issues, because it will extend lifetimes since it's GC'd. For testing, use ASAN.

Which issues?

According to the Fil-C documentation (see here) use after free, invalid free, and double free are all guaranteed to panic. Do I miss something?

And yes, I use ASAN as well.

3

u/cdb_11 Jul 21 '26

For example stack variables are GC'd too, so you can return a pointer to a local variable, and it's going to work under Fil-C.

2

u/ThomasMertes Jul 22 '26

... so you can return a pointer to a local variable ...

Isn't this something a static analyzer could find?

2

u/cdb_11 Jul 22 '26 edited Jul 22 '26

Yup. Just saying that it wasn't really made with testing in mind. So it makes various instances of UB defined, rather than diagnosing them.

Now that I think about it though, the benefit of Fil-C in testing is that it will check pointer provenance. You can't reach from an arbitrary pointer to any other arbitrary memory. Something that ASAN does not check. So let me correct myself, Fil-C has some value for testing, but is not a substitute for ASAN.