4 ms·
Here's an example of a quite high profile Rust project discovered to have been (ab)using unsafe: https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in_a
by jack1243star 8y ago
Here's an example of a quite high profile Rust project discovered to have been (ab)using unsafe:
https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in_actixweb_other_libraries/ https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in...
- steveklabnik 8y ago... and, due to said awareness, the issues were all fixed. The presence of the unsafe keyword made the audit much easier. Everything is working as intended!
- HugoDaniel 8y agohttps://github.com/actix/actix-web/search?utf8=%E2%9C%93&q=unsafe&type= https://github.com/actix/actix-web/search?utf8=%E2%9C%93&q=u...
- Nimelrian 8y agoGood rust code doesn't have to be free of unsafe blocks. In some cases you can't avoid them, e.g. when doing memory mapping. Instead, the unsafe blocks semantically designate areas you should keep an eye on. I rather have 20 unsafe one-liners surrounded by safe wrappers in a project with several thousand LOC, than a 1k LOC C project where I have to take extra care with every step.
- steveklabnik 8y agoSure. I haven’t looked at these exact blocks, but the point is that they were using tons of unsafe that they didn’t need to. Unsafe exists to be used, when it’s neccesary. 11 now? Iirc it was on the order of 100 before.
- HugoDaniel 8y ago11 files, showing only the top two references per file. In a proper grep it shows about 35 unsafe references. Not bad indeed.
- phkahler 8y agoFrom that link: >> Folks who are considering using actix-web might want to follow this thread about its heavy use of unsafe Rust. It's one thing to make heavy use of a small bit of unsafe Rust. It's another to use unsafe heavily - like someone who just refuses to use the language properly and therefore just keeps writing unsafe code. It's not clear from the wording which case this was but they do say it was fixed, rather than declaring it an unmitigated disaster ;-)