Re: C aggregate passing (Rust kernel policy)

Ralf Jung
2025-02-26T14:01:38Z

Hi all,

>> I think the one thing that's missing w.r.t. aliasing that Rust could
>> maybe use is a kasan-style sanitizer, I think with treeborrows and "now
>> we have an actual model for aliasing optimizations" it should be possible
>> to write such a sanitizer. But the amount of code doing complicated
>> enough stuff with unsafe should really be quite small, so - shouldn't be
>
> Miri implements those models and can check code for conformance. It
> can be used easily in the Rust playground (top-right corner -> Tools
> -> Miri):
>
> https://play.rust-lang.org
>
> However, it does not work when you involved C FFI, though, but you can
> play there. For more advanced usage, e.g. testing a particular model
> like Tree Borrows, I think you need to use it locally, since I am not
> sure if flags can be passed yet.
>
> I would like to get it, plus other tools, into Compiler Explorer, see
> e.g. https://github.com/compiler-explorer/compiler-explorer/issues/2563.

By default (and on the playground), Miri will check Stacked Borrows rules. Those
are almost always *more strict* than Tree Borrows rules.

Unfortunately playground does not let you pass your own flags, so yeah getting
Miri on godbolt would be great. :D

Kind regards,
Ralf