Re:Beej's Guide to C Programming
by saagarjha on Monday March 06, 2023 @02:17AM
(#35038323)
> What does the actual performance look like?
Hard to say, production hardware isn’t out yet. Anyways, I think you misunderstand my point, CHERI is definitely designed for running C/C++ code but obviously people will want to run Rust on it. In that scenario capabilities are “free” because they exist by default (just like MMUs give you protection for no cost because they’re always on for modern OSes), so Rust can work with it.
> If it helps WUFFS can emit high performance C number crunching code that is definitely bounds safe
WUFFS is cool but it’s not really meant for general-purpose code.
> Until Rust the main consumers of optimising compilers which heavily rely on provenance shenanigans were C and C++ and in both languages you could just scare off the repeated bug reports resulting from such shenanigans by pointing at DR/260 in which WG14 basically says "Yes pointer provenance is a thing" but declines to specify how it could possibly work and leaves it to compilers to do whatever they want.
I think this lacks context. The compilers of yesteryear and even mostly the compilers of today can’t do much with provenance, because doing optimizations on it often requires global program analysis that is infeasible to perform. The examples that people knew were problematic were almost all centered around surprising compilation results in small snippets showing things like “off the end” pointers having the same bit pattern as the address of the stack object next to it, but comparing different. The responses to bug reports like these was not that provenance was broken but mostly “the standard doesn’t really want you doing stuff like this anyways, so go away”.
The actual legitimate use of provenance mostly did work, which was stuff like pointer tagging and stuffing (requiring round trips through various integer representations) for language runtimes and the like. Authors of that code typically worked really close to the hardware to questions like “does this pointer have provenance” doesn’t really mean much to them, they’d expect that it compiled to a load instruction like they expected and for the most part compilers would play it conservative and assign arbitrary provenance to operations like that. The exploration of “hmm, maybe we should specify this better” is a recent phenomenon that was done mostly independently of Rust the language but obviously a lot of those people were involved because the compiler/LLVM community is comprised of Rust people too.
Hard to say, production hardware isn’t out yet. Anyways, I think you misunderstand my point, CHERI is definitely designed for running C/C++ code but obviously people will want to run Rust on it. In that scenario capabilities are “free” because they exist by default (just like MMUs give you protection for no cost because they’re always on for modern OSes), so Rust can work with it.
> If it helps WUFFS can emit high performance C number crunching code that is definitely bounds safe
WUFFS is cool but it’s not really meant for general-purpose code.
> Until Rust the main consumers of optimising compilers which heavily rely on provenance shenanigans were C and C++ and in both languages you could just scare off the repeated bug reports resulting from such shenanigans by pointing at DR/260 in which WG14 basically says "Yes pointer provenance is a thing" but declines to specify how it could possibly work and leaves it to compilers to do whatever they want.
I think this lacks context. The compilers of yesteryear and even mostly the compilers of today can’t do much with provenance, because doing optimizations on it often requires global program analysis that is infeasible to perform. The examples that people knew were problematic were almost all centered around surprising compilation results in small snippets showing things like “off the end” pointers having the same bit pattern as the address of the stack object next to it, but comparing different. The responses to bug reports like these was not that provenance was broken but mostly “the standard doesn’t really want you doing stuff like this anyways, so go away”.
The actual legitimate use of provenance mostly did work, which was stuff like pointer tagging and stuffing (requiring round trips through various integer representations) for language runtimes and the like. Authors of that code typically worked really close to the hardware to questions like “does this pointer have provenance” doesn’t really mean much to them, they’d expect that it compiled to a load instruction like they expected and for the most part compilers would play it conservative and assign arbitrary provenance to operations like that. The exploration of “hmm, maybe we should specify this better” is a recent phenomenon that was done mostly independently of Rust the language but obviously a lot of those people were involved because the compiler/LLVM community is comprised of Rust people too.