4 ms·
I am not exactly sure of the point of this comparison. The OP got it right. There is not enough adoption. Of course you will find less programs with bugs, becau
by johnisgood 7y ago
I am not exactly sure of the point of this comparison. The OP got it right. There is not enough adoption. Of course you will find less programs with bugs, because there are less programs written in Rust! That, and in case of rewrites, they are almost nowhere complete functionality-wise.
I see that there is one use-after-free bug, and lots of out of range access bugs. How does that happen?
- roca 7y agoFuzz bugs in C and C++ code very often produce exploitable memory corruption. Fuzz bugs in Rust code very rarely produce exploitable memory corruption. This is independent of the absolute volume of code that you test or the total number of bugs that you collect. > I see that there is one use-after-free bug, and lots of out of range access bugs. How does that happen? The use-after-free bug was in explicitly unsafe Rust code (via the "unsafe" keyword). I assume that code was intended to be a performance optimization, but I haven't looked at the details. An "out of range" bug here is typically an array-index-out-of-bounds, which results in a panic (safe abort) at run-time. Panics aren't great but they're not exploitable.
- steveklabnik 7y ago> I see that there is one use-after-free bug, and lots of out of range access bugs. How does that happen? The use after free [1] is because of unsafe code, specifically, a function that says "trust me, I know what the type of this is." I only checked a few of the "out of bounds" bugs, and they all are panics [2], which are not memory unsafe. Of course, someone could cause a real one with the use of unsafe. 1: https://github.com/shepmaster/sxd-document/issues/47#issuecomment-311688608 https://github.com/shepmaster/sxd-document/issues/47#issueco... 2: https://github.com/image-rs/image-tiff/issues/28 https://github.com/image-rs/image-tiff/issues/28
- youdontknowtho 7y agoSomeone else mentioned it in another thread, but the propagation of issues related to code in unsafe regions to other sections of code that are nominally safe is an ongoing research area. It sounds really cool, though. Would love to hear more about it.
- steveklabnik 7y agoI think that's a bit exaggerated. The limits are known: unsafe code can cause problems when combined with any other code in the same module. If you use unsafe, you need to check the whole module, not just the unsafe block. This has been known for a long time, but people tend to not go into detail when talking about this because it's laborious and not really the point.
- johnisgood 7y agoI know that I could probably find this out myself but is there a command-line switch that would make the use of unsafe {} a compile-time error? Of course the alternative is just a quick grep for it, but personally I would feel safer if the code did not compile at all in the presence of a compiler switch/flag and unsafe blocks.
- steveklabnik 7y agoSo, there is, but it only works for your code. You can do it via an attribute in the source (#![forbid(unsafe)]) or via a command line flag (cargo rustc -- -D unsafe). This will not check your dependencies. You can use other tools, like cargo-geiger https://github.com/anderejd/cargo-geiger https://github.com/anderejd/cargo-geiger to check your dependencies. And of course, at the lowest levels, doing anything useful requires unsafe, since your operating system doesn't expose a Rust API to do tasks.
- johnisgood 7y agoThank you! I will use that attribute wherever I can.