|
|
|
|
|
by Animats
3336 days ago
|
|
Right. That's the road to buffer overflow exploits. The most recent CERT advisory reporting a buffer overflow exploit was April 17th, 2017.[1] About one per week is reported, year after year.
Others not reported are probably being exploited. Rust can stop that, but one "unsafe" declaration can break Rust's safety. Hash maps need to be 100% safe code. They're complicated, and involve elaborate calculations that output subscripts. [1] http://www.kb.cert.org/vuls/id/676632 |
|
It is not easy to do the same with a C library where it's basically prone to overflow issues everywhere.
These are vastly different issues. Yes, we should totally be strict on unsafe code. No, it is not the end of the world when the stdlib hashmap uses unsafe code. Unsafe is designed exactly for this purpose, dealing with the innards of safe abstractions. It does it well, and the hashmap code is pretty ok here.
(Sure, if it has a design which could be done in safe Rust, it should, but I suspect with the way the robin hood stuff works it might not. this has been on my list of things to do when I get more time, primarily to just learn about the hashmap impl, but also to improve it if possible)