by bjourne · 7y ago · 0 comments
I guess the fanboys will complain for me calling Rust unsafe. You can write "safer" programs in Rust just like you can in C++. They are however not as fast as those using unsafe parts of the language. You will never get the same kind of total safety as you get in, say, Python because Rust doesn't do overflow checking. It does in debug mode, but you are strongly encouraged to distribute binaries in release mode since the speedup is substantial.
Offering safety and programming ergonomics for performance is a crappy trade.
https://hackernoon.com/python-sandbox-escape-via-a-memory-co...
I'd say more people have had to jump into "unsafe" Python than have had to jump into "unsafe" Rust.
As for overflow checking, that won't lead to unsafety on its own, just panics (it's defined to wrap in release).
Your post conflates all sorts of issues and lacks nuance.
A wrap around on its own can not cause unsafety in rust, only panics.
As in, maybe you try to use the wrapped integer as an array index, that's still safe even if it wraps (because Rust bounds checks).
It would only case memory safety when used alongside code in an unsafe block.
> The author says that it is very hard not easy to exploit C libraries loaded by Python.
I drew a different conclusion from that section
You are either misinformed or do not know what safety means. Integer types in Rust in release mode wraps around and that can lead to consequences much worse than crashing. Programs doing the exact opposite of what they were intended to.
Now I see that you are talking about MEMORY safety which I'm not. Writing safe programs includes so much more than just memory safety.
> I drew a different conclusion from that section
I have not seen a single CVE about the issue.
Someone needs to write the unsafe code so that the safe code can execute on top of it.
And the first hypertext based software was developed at Xerox PARC, which also did not use any Bell Labs languages.
For Python and Ruby, it is a matter of someone actually taking the effort of doing it, which no one does because it would only be proving a point that anyone with major in compiler design already knows it is possible, just with lots of hard work.
I don't care about Ruby or Python, both toy languages.