Memory-safe C code
Memory-safe C code
Posted Nov 21, 2025 12:19 UTC (Fri) by khim (subscriber, #9252)In reply to: Memory-safe C code by anton
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
> There were several C implementations that caught bounds violations presented at the poster session of PLDI 2002 (probably elsewhere, too, but I was involved in that poster session, so I remember that).
I'm, mostly, ignoring bound violations here: these were implemented in ALGOL 68, more than half-century ago, why are they even wort talking about? There were actually dropped out when ALGOL ideas were adopted into BCPL to create C.
Their reintroduction is a welcome change, but not ground-breaking at all.
The interesting part, as I wrote many time, is memory safety and the associated tracking of pointer validity.
Sorry if I was unclear, but I wrote that more than once and couldn't repeat that in every message here.
> Somehow that did not catch on, but in recent years I have read about similar things, this time including protection against dangling pointers and double free, with even fatter pointers.That's different from what we are discussing here, though: Rust does things in compile time, isn't it? For the C variant to be ground-breaking it needs that, too.
Of course C that may achieve safety with fatter pointers is nice thing, obviously… just not ground-breaking.
> After the research project ended (AFAIK in 2009 or so), nobody productized this work, so apparently it was not "very interesting" to the C programmers at the time.Obviously. C programmers were secure in their knowledge that they are indispensable… only when Rust have grown to the point where there are more new Rust code in Android they started thinking about doing something. It's typical situation with disruptive innovations.
> I still think it's saner to add some annotations to a C program than to rewrite it in Rust, but apparently there is some cultural hurdle that cannot be taken: Some programmers welcome the checking, but they don't program in C, not even in deputized C; other programmers program in C, but they are not interested in the features that Ivy/Deputy or the fat-pointer C implementations offer. And it seems to me that this is just as true now as it was 20 or 10 years ago.It's the same story with all disruptive innovations. Story, typically, happens like this:
- Year
Y0: disruptive innovation happen, but couldn't be immediately adapted by users of “old tech” because there are lots of problems with it. Adoptions happens in the “new industry”, instead. - Year
Y0 + N: two things are happening:
• “New teach” is improved enough to start being used in places where “old tech” is dominating.
• “Old tech” developers wake up and start new project to bring “old tech” to the parity with “new tech”. - Year
Y0 + 2*N: two things are happening:
• “New tech” is adopted by almost everyone (90% of developers either use it or would never adopt new innovations at all)
• “Old tech” have grown to the point where it's on the parity with “new tech”… but nobody cares anymore.
See the problem? Disruption (and, often, destruction of “old tech”) happening not because it's not possible to extend the “old teach”, but because between stages #1 and #2 users of “old teach” are not interested (and thus technology is not developed and not adopted), while between stages #2 and #3 they are interested and they already have they way forward: adopt the “new teach”.
Here, with Rust:
- Year 2015: Rust appears, but have too many deficiencies to be used in all places where C is used — no inline assembler, borrow checker is extremely painful, etc.
- Year 2025:
• Rust is growing like a weed.
• C people take notice and start reforming C. - Year 2035 (prediction):
• Rust is adopted almost everywhere.
• C got C35, developers of C35 have finally made something as good as Rust… and nobody cares anymore.
