Live data from Hacker News

Bugs Rust won't catch

corrode.dev

61–70 of 395 posts

Re: Bugs Rust won't catch

#61
post #60

Earlier quoted context omitted.

Nobody believes Rust programs are but free, though. Rust never promised that. It doesn't even promise memory safety, it only promises memory safety if you restrict yourself to safe APIs which simply isn't always possible.

> it only promises memory safety if you restrict yourself to safe APIs which simply isn't always possible. Less than that actually, considering Rust has its own definition of what "safe" means.

Ah, the Dwarf Fortress approach :)

https://dwarffortresswiki.org/DF2014:Fun&redirect=no

Re: Bugs Rust won't catch

#62
post #21

Earlier quoted context omitted.

Yes, it's the lack of Unix experience that's terrifying. So many of mistakes listed are rookie mistakes, like not propagating the most severe errors, or the `kill -1` thing. Why were people who apparently did not have much experience using coreutils assigned to rewrite coreutils?

Why is it even possible to represent a negative PID, let alone treat the integer -1 as a PID meaning "all effective processes"? This seems like a mistake (if not a rookie mistake) in the Linux kernel API itself.

Pretty much all the rough edges being discussed here are design mistakes in Linux or Unix, and/or a consequence of using an unsafe language with limited abstractions and a weak type system. But because of ubiquity, this is everyone’s problem now.

Re: Bugs Rust won't catch

#63
post #46
post #2

> What’s notable is that all of these bugs landed in a production Rust codebase, written by people who knew what they were doing They knew how to write Rust, but clearly weren't sufficiently experienced with Unix APIs, semantics, and pitfalls. Most of those mistakes are exceedingly amateur from the perspective of long-time GNU coreutils (or BSD or Solaris base) developers, issues that were identified and largely hash…

Memory safety catches buffer overflows. CI catches logic bugs. Neither catches the Unix API gotchas nobody documented.

LLM account

Re: Bugs Rust won't catch

#64
post #58

The title of this article should be "Rust can't stop you from not giving a fuck" or "Rust can't give a fuck for you." --- > What’s notable is that all of these bugs landed in a production Rust codebase, written by people who knew what they were doing ... [List of bugs a diligent person would be mindful of, unix expert or not] --- Only conclusion I can make is, unfortunately, the people writing these tools are not goo…

> Pretty shocking to see the lack of basic thought going into writing what is meant to be critical infrastructure

uutils did not start off as "let's make critical infrastructure in Rust", it started off as "coreutils are small and have tests, so we're rewriting them in Rust for fun". As a result there's needed to be a bunch of cleanup work.

Re: Bugs Rust won't catch

#65
post #58

The title of this article should be "Rust can't stop you from not giving a fuck" or "Rust can't give a fuck for you." --- > What’s notable is that all of these bugs landed in a production Rust codebase, written by people who knew what they were doing ... [List of bugs a diligent person would be mindful of, unix expert or not] --- Only conclusion I can make is, unfortunately, the people writing these tools are not goo…

I love Rust, but I wonder if this is an example of the idea that its excellent type system can lull some people into a false sense of security. Particularly when interfacing to low-level code like kernel APIs, which are basically minefields inadvertently designed to trick the unwary, the Rust guarantees are undermined. The extent of this may not be immediately obvious to everyone.

Re: Bugs Rust won't catch

#66
post #21

Earlier quoted context omitted.

Yes, it's the lack of Unix experience that's terrifying. So many of mistakes listed are rookie mistakes, like not propagating the most severe errors, or the `kill -1` thing. Why were people who apparently did not have much experience using coreutils assigned to rewrite coreutils?

Why is it even possible to represent a negative PID, let alone treat the integer -1 as a PID meaning "all effective processes"? This seems like a mistake (if not a rookie mistake) in the Linux kernel API itself.

-1 is a special case, a way to represent a PID with all bits set in a platform-independent way. It's not very clean, and it comes from ancient times when writing some extra code and storing an extra few bytes was way more expensive.

Re: Bugs Rust won't catch

#67
post #58

The title of this article should be "Rust can't stop you from not giving a fuck" or "Rust can't give a fuck for you." --- > What’s notable is that all of these bugs landed in a production Rust codebase, written by people who knew what they were doing ... [List of bugs a diligent person would be mindful of, unix expert or not] --- Only conclusion I can make is, unfortunately, the people writing these tools are not goo…

> Pretty shocking to see the lack of basic thought going into writing what is meant to be critical infrastructure uutils did not start off as "let's make critical infrastructure in Rust", it started off as "coreutils are small and have tests, so we're rewriting them in Rust for fun". As a result there's needed to be a bunch of cleanup work.

Okay, thanks for the context, but aren't distributions eager to adopt these? Are current GNU coreutils a common vulnerability vector?

> For fun

My idea of fun is reviewing my code and making sure I'm handling errors correctly so that my software doesn't suck. Maybe the people who are doing this, for fun, should be more aligned with that mentality?

Re: Bugs Rust won't catch

#68
post #21

Earlier quoted context omitted.

Yes, it's the lack of Unix experience that's terrifying. So many of mistakes listed are rookie mistakes, like not propagating the most severe errors, or the `kill -1` thing. Why were people who apparently did not have much experience using coreutils assigned to rewrite coreutils?

Why is it even possible to represent a negative PID, let alone treat the integer -1 as a PID meaning "all effective processes"? This seems like a mistake (if not a rookie mistake) in the Linux kernel API itself.

It feels a bit like a "better is better" language hitting all of the quirks of a "worse is better" environment.

Re: Bugs Rust won't catch

#69
post #8

Earlier quoted context omitted.

More than that: it seems that Rust stdlib nudges the developer towards using neat APIs at an incorrect level of abstraction, like path-based instead of handle-based file operations. I hope I'm wrong.

Nearly every available filesystem API in Rust's stdlib maps one-to-one with a Unix syscall (see Rust's std::fs module [0] for reference -- for example, the `File` struct is just a wrapper around a file descriptor, and its associated methods are essentially just the syscalls you can perform on file descriptors). The only exceptions are a few helper functions like `read_to_string` or `create_dir_all` that perform sligh…

> For example, Unix's `rename` syscall takes two paths as arguments; you can't rename a file by handle

And then there’s renameat(2) which takes two dirfd… and two paths from there, which mostly has all the same issues rename(2) does (and does not even take flags so even O_NOFOLLOW is not available).

I’m not sure what you’d need to make a safe renameat(), maybe a triplet of (dirfd, filefd, name[1]) from the source, (dirfd, name) from the target, and some sort of flag to indicate whether it is allowed to create, overwrite, or both.

As the recent https://blog.sebastianwick.net/posts/how-hard-is-it-to-open-... talks about (just for file but it applies to everything) secure file system interaction is absolutely heinous.

[1]: not path

Re: Bugs Rust won't catch

#70

Earlier quoted context omitted.

Someone once coined a related term, "disassembler rage". It's the idea that every mistake looks amateur when examined closely enough. Comes from people sitting in a disassembler and raging the high level programmers who had the gall to e.g. use conditionals instead of a switch statement inside a function call a hundred frames deep. We're looking solely at the few things they got wrong, and not the thousands of correc…

When I read the article I came away with the impression that shipping bugs this severe in a rewrite of utils used by hundreds of millions of people daily (hourly?) isn’t ok. I don’t think brushing the bad parts off with “most of the code was really good!” is a fair way to look at this. Cloudflare crashed a chunk of the internet with a rust app a month or so ago, deploying a bad config file iirc. Rust isn’t a panacea,…

If I'm not mistaken, in the Cloudflare case, both the Rust rewrite and the C++ original version crashed. The primary cause being the bad config file.
Post reply on HN