Live data from Hacker News

Cross-platform Rust rewrite of the GNU coreutils

github.com

411–420 of 498 posts

Re: Cross-platform Rust rewrite of the GNU coreutils

#411

Earlier quoted context omitted.

You're giving a lot of strongly-worded advice/opinions on legal issues in this thread. Are you a lawyer? Can you point to any case-law to back up what you're saying? I'm not a lawyer, and I don't really know who's right in this thread, but I'd find any citations you have really interesting to read.

Here's an crazy thought: when lawyers are in court, one of them is always wrong. Imagine that. A lawyer being wrong. Mind blown. Is your lawyer a software engineer? If not, he doesn't know anything! He has literally no idea. He can't even comprehend software. It would melt his brain. So you ask, how can I the holder of meagre so-called "Computer Science PhD", comprehend the the holy (and unspeakable) knowledge of tho…

Wow... No one said lawyers can't be wrong, but the law is complex, and if you haven't studied it, it's a pretty good bet you don't really understand all the details. It's pretty funny to see you belittle lawyers in the same paragraph you say any lawyer's mind would melt by the complexity of software. Having a PhD in CS doesn't make you an expert in the law, the economy, or any other field unrelated to CS.

I was going to respond to the wikipedia article, but I'm realizing that would be a waste of my time. Good luck with your crusade against the almighty lawyer-priests.

Re: Cross-platform Rust rewrite of the GNU coreutils

#412

Earlier quoted context omitted.

Well there's the rub - once you see the source code, it's tough to say you weren't influenced by it. In for-profit endeavors this kind of thing is typically done by having two separate groups of people, one that sees the competing product and writes detailed descriptions of behavior, and one that never sees the product, only the product of the first group. If you're careful about this and go to pains to keep the grou…

> you're considered tainted from an intellectual property perspective. No you're not. The law has exactly zero to say about this. The idea of "clean room" development is nothing more than a legal tactic used to ward off potential lawsuits from an aggressive adversary. It's in no way necessary to do this.

The law (case law) says more than zero about this. https://en.wikipedia.org/wiki/Clean_room_design#Case_law

Re: Cross-platform Rust rewrite of the GNU coreutils

#413

Earlier quoted context omitted.

That's not the worst of it: the truly intractable part is preventing use-after-free UB. The only ways to do this are (a) remove malloc from your language; (b) add a lifetime system (incompatible with all existing C libraries); (c) add a garbage collector (which most projects written in C will not accept for performance reasons).

I think that's mostly solved by changing the whole of the idea from "remove/disallow all undefined behavior" to "remove as much of the common needed undefined behavior as possible such that most programs need not really use it". Perfect is the enemy of good.

With portable software (as in, portability is more valuable than other factors), imperfect is the enemy. ;-)

Re: Cross-platform Rust rewrite of the GNU coreutils

#414

Earlier quoted context omitted.

That's not the worst of it: the truly intractable part is preventing use-after-free UB. The only ways to do this are (a) remove malloc from your language; (b) add a lifetime system (incompatible with all existing C libraries); (c) add a garbage collector (which most projects written in C will not accept for performance reasons).

And once you've eliminated that, you have DoS bugs like forcing infinite loops, abandoned (referenced but unused) memory leaks, and worst-case hash table insertions. All of those are serious attacks for anything with a resource budget.

rlimit ftw

Re: Cross-platform Rust rewrite of the GNU coreutils

#415

Redox has been working on smaller, more BSD-like versions of the basic Unix utilities, also written in Rust: https://github.com/redox-os/coreutils I am excited to see this as I was working on a similar project last year (rewriting the BSD userland in Rust), but it's from pre-1.0 Rust so not really as idiomatic as what is coming out of the Redox project.

From the README: "These are based on BSD coreutils rather than GNU coreutils as these tools should be as minimal as possible." If all of these utilities are running in userspace, per Redox's microkernel architecture, then what is the advantage of intentionally not making them feature-rich?

It has the advantages that come from following the UNIX style. To learn more, I recommend reading this short paper by Rob Pike and Brian Kernighan, published in 1984: http://harmful.cat-v.org/cat-v/unix_prog_design.pdf

Re: Cross-platform Rust rewrite of the GNU coreutils

#416
post #402

Earlier quoted context omitted.

> Even specifying that they have a new arbitrary value on each access would be a big improvement over the status quo. This is approximately what LLVM describes undef as, and it indeed leads to nasal demons. This description enables a single value to both pass a bounds check, and then subsequently go out of bounds!

You're right, in certain cases it would still cause trouble, but it would be a lot fewer cases than 100%. Reading only once would be safe, and passing it to another functions would make a variable that can no longer change unexpectedly.

Unless the function is inlined/the compiler can deduce that the variable is undef.

(Of course, you could define it to work, but I would suspect that would make this sort of value much less useful.)

Re: Cross-platform Rust rewrite of the GNU coreutils

#417
post #76

Earlier quoted context omitted.

Prof. Regehr did not find problems with SQLite. He found constructs in the SQLite source code which under a strict reading of the C standards have “undefined behaviour”, which means that the compiler can generate whatever machine code it wants without it being called a compiler bug. That’s an important finding. But as it happens, no modern compilers that we know of actually interpret any of the SQLite source code in…

Can you suggest what that change might be related too? I, too, think it's less likely than one might think. This discussion seems to miss a couple things. SQLite is embedded quite often, by programs written in C; would embedding a rust library and possibly runtime fix things? The parent program would still potentially have defects and those defects could impact SQLite. SQLite is also rather mature, I do t see how you…

> Can you suggest what that change might be related too? I, too, think it's less likely than one might think.

Aliasing rules[1]? Compilers apparently don't agree on that now, so even if it were to coalesce into the same undefined behavior, one would have to change.

> This discussion seems to miss a couple things. SQLite is embedded quite often, by programs written in C; would embedding a rust library and possibly runtime fix things?

I'm not advocating for Rust as much as I'm advocating against C, or at least against C as it currently exists and is implemented with so much undefined behavior. I've argued elsewhere in this discussion that a special subset of C with as much undefined behavior as possible specifically defined, which could be enabled through a flag, would do wonders (even if at the expense of some portability).

> Take OpenSSL as an example, they are t tossing it, they are fixing it, it's a much more shallow lift to fix it.

It's much more shallow to review and patch it. Let's not kid ourselves that it will be fixed when they are done with it. There will likely be bugs regardless of the language used to implement a crypto library. Does that mean we should ignore when one language allows an entire class of bugs that another does not, especially when it's for a Crypto library?

Let me make my case another way. What if C nevercaught on as the dominant language, or C was defined originally in a more strict manner, and most the utilities and tools we take for granted were instead implemented in a language that had less undefined portions, allowed less undefined behavior, and thus had less bugs and security problems? Would the resultant small performance hit (due to being unable to optimize around the undefined behavior) outweigh the added stability and security, or would we have been better off? I think we would have been better off, and I think since C's still widely in use, it's not too late to make that case.

1: https://news.ycombinator.com/item?id=11288665

Re: Cross-platform Rust rewrite of the GNU coreutils

#418

Earlier quoted context omitted.

I think that's mostly solved by changing the whole of the idea from "remove/disallow all undefined behavior" to "remove as much of the common needed undefined behavior as possible such that most programs need not really use it". Perfect is the enemy of good.

With portable software (as in, portability is more valuable than other factors), imperfect is the enemy. ;-)

We have over four decades history of portability being valued over correctness, stability and security. I'm not impressed with where it's gotten us.

Re: Cross-platform Rust rewrite of the GNU coreutils

#419
post #348

Earlier quoted context omitted.

The readline library for example. If I want to use it, I have to GPL my whole program. I probably might not have modified readline at all. Or any other GPL software which gets somehow linked together with my code. Just watch the controversy whether ZFS kernel modules may be delivered as pre-compiled binaries (sources are fully available). The output of compilers and parsers which are GPLed, also are implicitly covere…

Yeah if you link libreadline you have to GPL your source, but why do you consider that bad? Isn't that in the interest of the general public?

It is in the interests of a minority of programmers, themselves a tiny minority of the general public. Let's not get completely overblown about the stakes here.

Re: Cross-platform Rust rewrite of the GNU coreutils

#420

Earlier quoted context omitted.

But Powershell redirects either don't work or can corrupt your files

You might find this useful: https://technet.microsoft.com/en-us/library/hh847746.aspx

A) That's only one direction, the other way doesn't work

B) Even going that direction, at times it corrupts the data

Post reply on HN