Re:Rust and C++ Interoperability in Chrome
by coder543 on Wednesday August 19, 2020 @06:29PM
(#24217544)
Yes, but good luck getting that through any form of code review. The unsafe block and the raw pointers or the call to transmute make it pretty obvious that something fishy is going on that’s worth reading carefully. ¯\_/(ツ)\_/¯
Unlike C or C++, where it can sometimes be harder to tell what the lifetime of something should be, or whether you’re extending the lifetime of a reference beyond the point that it is safe.
Unsafe definitely gives you loaded footguns... which for the umpteenth time is why it is considered a code smell. Sometimes you have to write smelly code, but it’s something to be avoided.
Re:Rust and C++ Interoperability in Chrome
by jcelerier on Thursday August 20, 2020 @03:09AM
(#24220684)
> Yes, but good luck getting that through any form of code review.
do you think more than a few percent of the "foundational" OSS projects where we find all the classical CVEs have any code review process ?
You can do serious damage with those things though. One tactic I have done is to expand the lifetime of a reference by laundering it through a raw pointer, since the function to convert a raw pointer to a reference allows you to choose any lifetime you want.