Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am 99% sure that OP did not checked the code and made sure that Rust could have been used there without using unsafe, so maybe you could only say "maybe Rust and any other memory safe language would avoid that issue" but since is code related with VMs and JIT you may have use the unsafe things in those languages so maybe it was not avoidable.


If the type of bug is use after free, double free, race condition or uninitiated memory - Rust would have dealt with it.


And if the code was not part of an unsafe section of Rust code. I have nothing against advocating for your favorite software but if you do it wrong by "omitting" things it will backfire, as a Linux user I seen this thing happen, you get some fanboy convincing people to use Linux, usually Arch because that distro attracts fanboys then the new user finds the ugly parts that were not advertised and runs screaming.


This is specious reasoning. You have to go out of your way to write unsafe broken code. The default in Rust is for memory safety. Yes, someone could theoretically be using an unsafe block and raw pointers to manipulate a memory buffer. But they probably aren't, because that's generally pretty stupid unless you're implementing a higher-level wrapper around the buffer, which very few people do because there's generally already a wrapper that does what you want (often provided by the stdlib). And even if you are, the unsafe code is contained in a very small area which makes it much easier to review for safety.


I was talking about the low level code like in this case where you interact with the kernel, for calling kernel/OS functions you will have to pass pointers and buffers around,I am not sure if you can wrap the kernel functions without making things slower by adding indirection.


For any call that takes a raw pointer and a length, you can create a trivial wrapper that takes a &[u8] or &mut [u8] instead in order to make it safe. And you probably should do that, because you don't want to be sprinkling `unsafe` throughout your entire codebase. If you're really worried about indirection, you can also mark these inline, but they're small enough that the compiler would probably inline them anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: