3 ms·
How about writing a minimal pseudo-Rust compiler that treats all invalid Rust code as undefined behavior? This would be a lot easier than reimplementing the rea
by mrob 10y ago
How about writing a minimal pseudo-Rust compiler that treats all invalid Rust code as undefined behavior? This would be a lot easier than reimplementing the real Rust compiler, because a lot of the complexity is in the compile time error checking (eg. the borrow checker) and the detailed error messages. The original Rust compiler could be used to check the code is valid first. Would this be any use for diverse double compiling style countermeasures? You might be able to write a backdoor that both circumvents the error checking in the real Rust compiler and exploits undefined behavior in the pseudo-Rust compiler, but this must be more difficult than a traditional trusting trust attack.
- Manishearth 10y agoI think that borrow checking is only a minor part of the complexity. You still need to do most of type checking for type and method resolution. So it would be easier, but not much easier. But yes, such a compiler can be used.
- comex 10y agoSomeone has tried to do something along those lines: https://github.com/thepowersgang/mrustc/blob/master/README.md https://github.com/thepowersgang/mrustc/blob/master/README.m... > Thankfully, (from what I have seen), the borrow checker is not needed to compile rust code (just to ensure that it's valid) It's not finished, though, and honestly I'm pretty sure that borrow checking isn't even that hard compared to all the other stuff a Rust compiler has to do, like generic/trait resolurion. But we'll see.
- naasking 10y ago> It's not finished, though, and honestly I'm pretty sure that borrow checking isn't even that hard compared to all the other stuff a Rust compiler has to do, like generic/trait resolurion. You can implement basic trait resolution via name mangling and a global map. I did this as an experiment a number of years ago to implement type class-like overloading in C. I'm not sure how far you could take that technique though. I don't think it would work for higher-kinded types, but Rust doesn't have those.