Better HN
topnewbestaskshowjobs
Log inSign up

afdbcreid

1,230 karma · joined Nov 10, 2020 (6y ago) · 503 submissions

Submissions

comment 7h ago · link · parent

Oops, I read "LLMs" as "LLVM" and thought it was referring to Clang's lifetime annotations, and asking why they cannot be inferred :(

Truly embarrassing.

comment 12h ago · link · parent

That's actually the opposite: to avoid trusting trust attacks you need to remove Rust from the bootstrap chain, not C++.

comment 12h ago · link · parent

That doesn't work because it's global and borrow checking is quadratic (cubed maybe even, not sure).

comment 13h ago · link · parent

Oh, it seems you're right. I wasn't aware of this. Interesting.

comment 22h ago · link · parent

That's not a justification for why we want that when compiling to other platforms though. CHERI indeed chooses to have provenance for pointers and not integers, but it's not the only possible choice (even though it is the best choice, but we want to justify it here).

comment 22h ago · link · parent

> If by "that's not true" you mean "that would be a bug in LLVM" then, uh, yeah, we know that it's a bug in LLVM.

No that's not what I meant. Of course there is a bug in LLVM, but I said there will be no miscompilations and meant that - because with strict provenance, we don't use the problematic constructs (that LLVM miscompiles).

> No, integers shouldn't have provenance. Due to this compiler bug unfortunately we can give integers provenance and blow up the world.

Nope that's incorrect. In LLVM (and all other compilers I know) integers do not have provenance, and there aren't any optimizations that think they do. The bug (as understood by experts) is in pointer handling and not integers, specifically that ptr2int is not treated as having side-effects and that int2pt is considered to give the same pointers for the same integers.

comment 1d ago · link · parent

> However, there are extant examples where you can just trick LLVM into asserting that two integers a,b are different and then showing that a - b == 0 which proves it was lying, those are by definition miscompilations and they don't rely on Exposure, they're just getting the LLVM optimiser to apply a pointer provenance optimisation to a thing it was just told is not a pointer.

If I'm getting what you mean correctly, that's not true. Integers do not have provenance and if `a - b == 0` then `a == b` when a, b are integers. The problem is only when LLVM concludes from this that `a as *const _ == b as *const _`, and that doesn't exist for strict provenance.

comment 1d ago · link · parent

You definitely can be safe in C as well - the difference I noted is that in Rust the safe pattern is officially blessed and the unsafe pattern is officially unblessed.

comment 1d ago · link · parent

That is indeed the semantics most people want, but justifying why is not trivial, and it's also not trivial to formally specifying everything with this view.

comment 1d ago · link · parent

Assembly indeed has a very easy exit in such issues (and in UB in general).

comment 1d ago · link · parent

Do note though that strict provenance in Rust does work (at least we're not aware of any miscompilation AFAIK), and pre-strict-provenance semantics, or exposed provenance semantics, are warned against in the docs and clarify that they do not have accepted formal semantics. So the situation is a bit better than C.

comment 1d ago · link · parent

> However in C, which most of the examples are written in, the status is a bit less clear.

I believe it's a bit of an exaggeration. Formally specifying int2ptr and ptr2int casts in a way that permits both all code found in the wild (or at least a large majority of it) and all optimizations compilers want to perform (ditto), is more than just a bit difficult.

comment 1d ago · link · parent

I'm not a C expert, however I do follow Rust's discussions about pointer provenance. It might be unspecified but people do rely on this (e.g. pointer tagging is the same under your explanation), and even CHERI uses hacks to not break them, at least whenever possible. Furthermore the standard says in a footnote:

> The mapping functions for converting a pointer to an integer or an integer to a pointer are intended to be consistent with the addressing structure of the execution environment.

So even if it's not mandatory, it is expected to work.

comment 2d ago · link · parent

Funny that this codebase is 62% Rust, 9% Python. And I'm a huge Rust proponent.

comment 5d ago · link · parent

> BTW, some popular malloc/free implementations are almost as big as Java's most complicated GC

I'm pretty sure that's incorrect by a wide margin, and that all non-nop GCs java has are as large as at least some popular allocators.

comment 5d ago · link · parent

Actually, Rust can have fully safe SIMD (Java too, but it's still in preview AFAIK).

comment 5d ago · link · parent

So is the JVM, and?

comment 5d ago · link · parent

Not accurate. Most datastructures that use unsafe in Rust are primitives; `Box`, `Vec`, `Rc`/`Arc`, `HashMap` and `BTreeMap`. Of those, only the equivalent to `HashMap` and `BTreeMap` are written in Java, and they can be written in safe Rust as well if you're willing to give up some of the performance (e.g. always initializing - thing that happens in Java as well). More complex data structures (e.g. graphs) can and often are implemented without unsafe at all.

comment 5d ago · link · parent

Arrays in Java (a loose equivalent of `Vec`) is a runtime primitive and implemented in a memory-unsafe language. References (loose equivalent of `Box` and `Arc`) as well. Java's `synchronized` (a loose equivalent to `Mutex`) as well. Those are not good counterexamples.

comment 1w ago · link · parent

Why do you need to do that? You can't be generic over "any enum using this tag" anyway (in Rust, at least). If you just want to make sure you make no mistake, you can use a dead match from the tag to the enum, or automate it with a macro, and the compiler will enforce exhaustiveness (though not on both sides, unless you use a macro).

comment 1w ago · link · parent

This is a minor advantage (but is an advantage) and when needed (rarely) you can usually workaround with a different fieldless enum and potentially a proc-macro to autogenerate it.

comment 1w ago · link · parent

As I've said in other places, supply chain risks have nothing to do with things not being in std, only with them not being official - and things can be (and are) official without being included in std.

Documentation certainly has nothing to do with it.

Other factors you mentioned are more convincing.

23.

Rust – Enabling the parallel front end on nightly(blog.rust-lang.org ↗)

10 points · by afdbcreid · 1w ago · discuss

24.

Jiff – A datetime library for Rust – reaches 1.0(burntsushi.net ↗)

15 points · by afdbcreid · 1w ago · 2 comments

comment 1w ago · link · parent

Rust is indeed not designed for quick compilation. Furthermore and unlike what you said, what makes it memory safe has pretty little to do with that. But what makes it fast definitely has to do with that, which is what I said.

comment 1w ago · link · parent

I agree that sometimes other languages are packaged this way as well, and maybe I was moving the goalposts. My original meaning was that only for C/C++ (on Linux) the recommended method of distribution is via the OS, while other languages have their own mediums (not requiring stable ABIs). So when they are packaged like that that's mostly because the OS itself or its services need them.

comment 1w ago · link · parent

But that's the thing: almost nobody ships software via the OS today. Even on Linux software is often managed in other ways.

comment 1w ago · link · parent

That still isn't a paradox. Furthermore it still makes sense: a language designed to generate the fastest code has constructs that cannot be compiled quickly, even without optimizations.

But some of it is implementation problems.

comment 1w ago · link · parent

That's not true. Scripting languages of course need no ABI. Managed languages like C# and Java often keep compatibility of the bytecode. Only AOT languages like Go and Rust cannot.

comment 1w ago · link · parent

> No, in that other than Rust and Go (and maybe a few others that emit single binaries, zig?) this is how it works with OS distributed programming language packages.

Uhmm... No? E.g.:

- Python has long strongly recommended virtual environments.

- Not to talk about JavaScript which of course manage things per project by default.

- I don't remember what was the state of things in .NET Framework, but in modern .NET NuGet packages are distributed as DLLs with your app.

I don't know other ecosystems well but I believe they aren't different.

12345
17