Memory-safe C code
Memory-safe C code
Posted Dec 2, 2025 11:02 UTC (Tue) by anton (subscriber, #25547)In reply to: Memory-safe C code by khim
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
Bounds checking is worth talking about, because Algol 60 (which usually was implemented with bounds checking) and Algol 68 failed to catch on (at least to the same degree as C), while C (which passes arrays as pointers without size information) caught on and a lot of code is written in C. Interestingly, in the Linux man-pages 6.03 I see things in the spirit of Deputy, like
void *memmove(void dest[.n], const void src[.n], size_t n);which indicates how n relates to the passed pointers. Is this a C23 innovation? In any case, some Deputy-like features are finding the way into C, 15 years later.
There are no invalid pointers in Lisp (released 1960) and many later languages (e.g., Java), so why are you talking about that? Because invalid pointers in C code are a problem, and there is lots of C code around.
Concerning compile-time vs. run-time checking, Ivy/Deputy is like Rust: Checking at run time what cannot be checked at compile time. Maybe Ivy/Deputy cannot do all the things that Rust can do, but that would be just an issue of adding the additional features to the safe C variant.
A bigger problem in that context is probably that in some cases you would either stay with unsafe C in significant pieces of code or have to do thinks like Rust does with Rc or Arc (run-time reference counting and checking), a cost that C programmers that think that their code is correct do not want to take, so they will leave the C code for handling the data structure unsafe. Still, I think that in much code, lots of code could be converted to such a safe C variant with less effort than rewriting it in Rust.
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
