I think this misses the real problem. So many pieces of foundational software like glibc and OpenSSL are understaffed, underfunded, and plagued by terrible code. Go read glibc getaddrinfo: it's a mess! Rewriting the software in Rust would not solve these problems any more than rewriting it in C++ would. A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that…
> A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that nobody has time to fix. The entire point is that you're not in the same situation regarding memory safety problems/vulnerabilities.
Rewrite Everything in Rust
41–50 of 242 posts
Re: Rewrite Everything in Rust
#42Off topic, but it's surprisingly refreshing to see someone put "Christian" next to their name in the same place they put "Mozilla hacker." The vast majority of programmers either aren't religious or hide it so well that you couldn't possibly tell if they were. (Not that being overt about it is better, either.) I understand that it's generally best not to talk religion in the professional workplace, but a person's own…
Re: Rewrite Everything in Rust
#43Re: Rewrite Everything in Rust
#44If a given piece of software has been largely written using certain patterns or conventions, then it is often possible for a syntactic rewrite engine to be able to match those patterns, then output idiomatic code patterns in the target language. This may well be applicable to kernels and other constituents of an OS.
Have you even looked at the source code to glibc? It's stuffed full of macros and #ifdef hell. Not to mention symbol versioning, the use of gcc-specific compiler extensions, and ancient-UNIX-beard performance hacks. You'd have more success teaching a chimpanzee to play the violin, than automatically translating glibc into anything.
in true.c (all told, an 80-line file):
/* Act like "true" by default; false.c overrides this. */
#ifndef EXIT_STATUS
# define EXIT_STATUS EXIT_SUCCESS
#endif
false.c, of course, contains only: #define EXIT_STATUS EXIT_FAILURE
#include "true.c"
On my current system, each of these represents a stately 27KB dynamically linked executable.By way of comparison, the OpenBSD version of true comprises nine lines with zero preprocessor directives:
/* $OpenBSD: true.c,v 1.1 2015/11/11 19:05:28 deraadt Exp $ */
/* Public domain - Theo de Raadt */
int
main(int argc, char *argv[])
{
return (0);
}Re: Rewrite Everything in Rust
#45If a given piece of software has been largely written using certain patterns or conventions, then it is often possible for a syntactic rewrite engine to be able to match those patterns, then output idiomatic code patterns in the target language. This may well be applicable to kernels and other constituents of an OS.
Have you even looked at the source code to glibc? It's stuffed full of macros and #ifdef hell. Not to mention symbol versioning, the use of gcc-specific compiler extensions, and ancient-UNIX-beard performance hacks. You'd have more success teaching a chimpanzee to play the violin, than automatically translating glibc into anything.
It does seem to me though that if you pre-processed it for a common case and translated it to rust with anything going into unsafe if it has to and started from that you would be off to some sort of start.
The whole thing seems moot though because there are already alternate libc implementations like musl as well as alternate malloc implementations like jemalloc.
I actually still don't understand why libc is the undertaking it is made out to be, especially if you can plug in jemalloc which I would think would take care of the most difficult part.
Re: Rewrite Everything in Rust
#46Re: Rewrite Everything in Rust
#47Earlier quoted context omitted.
> A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that nobody has time to fix. The entire point is that you're not in the same situation regarding memory safety problems/vulnerabilities.
I think what GP is saying that you'll have problems in logic or other typical programming problems and that it isn't a lack of language features/safety but rather time/money being thrown at these libraries I imagine the top two reasons unsafe memory access happen is: 1) other complicated logic seeped into the memory sensitive area or causes programmer fatigue 2) memory management is hard Rust helps with #2 but let's…
> Rust helps with #2 but let's not kid ourselves, what percentage of a library like glibc would be spent in unsafe blocks?
string.h is not as interesting as, say, the DNS resolver. Nothing about the DNS resolver needs to be unsafe.
Re: Rewrite Everything in Rust
#48I have actually started to do this to see for myself how much work it would be http://blog.dkhenry.com/2016/02/17/deciding-to-rewrite-getad...
Re: Rewrite Everything in Rust
#49Not this crap again. C libraries are not pretty but they have been out there for decades, they have been reviewed and used in production. There is no silver bullet, just because you use Rust it doesn't mean your programs will be completely safe. A lot of these C libraries were written in more innocent times where a small bug would not affect as many people as it would today. We live in a C world and I don't see that…
The same was true of Fortran when C came around. I'm glad K&R didn't use this reasoning in 1978 to justify not rewriting things in their new language.
> There is no silver bullet, just because you use Rust it doesn't mean your programs will be completely safe.
Nobody is claiming that Rust eliminates all security vulnerabilities.
> A lot of these C libraries were written in more innocent times where a small bug would not affect as many people as it would today.
This isn't a positive!
Re: Rewrite Everything in Rust
#50Earlier quoted context omitted.
> A rewrite would clean up the code, sure, but then you're left in the same situation, only with brand new bugs that nobody has time to fix. The entire point is that you're not in the same situation regarding memory safety problems/vulnerabilities.
Agreed, the hope is that the combination of Rust + a rewrite, you'd be in a MUCH better place than where we are now. I think an interesting question is, why are there so many contributors to the Linux Kernel in comparison to something like glibc? Both, I'd argue, are equally foundational.