Live data from Hacker News

Mitigating Memory Safety Issues in Open Source Software

security.googleblog.com

211–220 of 244 posts

Re: Mitigating Memory Safety Issues in Open Source Software

#211
post #57

While rust certainly does a lot of things right, it is still a moving target with a relatively high velocity. There is a python library that recently switched to rust (partially) and now cannot be build on several platforms. This also means that very long-lived platforms will probably be forced to upgrade that library every half year or so in line with the development of rust. I'd say such an initiative needs a long-…

>There is a python library that recently switched to rust (partially) and now cannot be build on several platforms.

Progress should not be held back for the rest of us because a few will get left behind. If you are running something so old that LLVM doesn't support it, upgrade. It's 2021.

Re: Mitigating Memory Safety Issues in Open Source Software

#212

Earlier quoted context omitted.

Go, Pony and Haskell all have complex runtimes and a GC, which makes them unsuitable for embedding into other applications or exposing them as widely usable libraries. Rust, Zig, and to a certain extent D or Nim without GC, can easily expose a C API and have a minimal runtime. But the others do not provide the same guarantees as (safe) Rust with the borrow checker. All very cool languages in their own right, but memo…

D now has a prototype borrow checker implemented.

That's very cool to hear!

As the ceator of D, how do you see the place of borrow checking in the ecosystem long term?

Would you imagine most D code to be written against the borrow checker in the future, with transparent convenience for GC types?

Or would it remain a somewhat niche feature for domains that can benefit?

Re: Mitigating Memory Safety Issues in Open Source Software

#213

Earlier quoted context omitted.

Go, Pony and Haskell all have complex runtimes and a GC, which makes them unsuitable for embedding into other applications or exposing them as widely usable libraries. Rust, Zig, and to a certain extent D or Nim without GC, can easily expose a C API and have a minimal runtime. But the others do not provide the same guarantees as (safe) Rust with the borrow checker. All very cool languages in their own right, but memo…

i just write all my projects in Haskell on any platform so the RTS is a given (or the RTS isn't present at execution time since the executable is generated from a Haskell eDSL) it's truly superior to any other programming language (5+ years of pro experience talking), so why waste my time with the manual labor of imperative programming?

I write 90% of my stuff in Haskell. When I need speed, I used to use C, now I use Rust.

> why waste my time with the manual labor of imperative programming

Someone has to. https://github.com/ghc/ghc/tree/master/rts

Re: Mitigating Memory Safety Issues in Open Source Software

#214
post #211
post #57

While rust certainly does a lot of things right, it is still a moving target with a relatively high velocity. There is a python library that recently switched to rust (partially) and now cannot be build on several platforms. This also means that very long-lived platforms will probably be forced to upgrade that library every half year or so in line with the development of rust. I'd say such an initiative needs a long-…

>There is a python library that recently switched to rust (partially) and now cannot be build on several platforms. Progress should not be held back for the rest of us because a few will get left behind. If you are running something so old that LLVM doesn't support it, upgrade. It's 2021.

LLVM does not support every proprietary embedded device. And even if it did, rust support does not come for free. (One must add support for the target ABI and other stuff)

Re: Mitigating Memory Safety Issues in Open Source Software

#215

Earlier quoted context omitted.

> I would call C++ a memory safe language C++ is not, in any sense, a memory safe language.

Then you don't know anything about C++, only the C legacy it is built on. Modern C++ has good data structures and good memory management. To be fair actually using those features of C++ instead of the C legacy is still catching on. Most instructors aren't even teaching it. Using C in C++ is like using unsafe everywhere in rust - you can do it, but you lose all the advantages.

    std::string_view xx = something_that_returns_a_std_string();
    use(xx); //oops

Re: Mitigating Memory Safety Issues in Open Source Software

#216
post #137

Earlier quoted context omitted.

I think you should reconsider the actual problem, if you do not understand it. The fact that rustc is backwards compatible is great, sure. But it does not solve the problem of distributors. Say you have libfoo-1.0 that uses rust and cargo 1.2 . A distributor that now releases their linux version and wants to ship libfoo-1.0 must consider the requirements for supporting it. This support usually outlives the upstream s…

I think you are missing the fact that the solutions are already in place for all of this. > One is the highly dynamic nature of cargo dependencies. libfoo might depend on a myriad of crates transitively and rust simply is too young to provide any experience in how long they will be available or supported. And no, it is generally not a good idea to update to new feature releases for security updates. This is something…

What I don't really like in cargo is its' overcentralized and author-centric approach. What if some of your dependencies relies on the crate, which author doesn't support anymore and doesn't even accept patches? You will basically have to maintain a fork either with a different name (because you can't push it to crates.io) or have a patched version which you also can't push and have to manually update every Cargo.toml of every dependency in your project to use your fork. And what if you have not only one Rust project in your complex system? You will have to update or vendor everything. This is a real maintenance hell.

While in C/C++ I can just build a fork as dynamic library and put it to the system image or to the own package manager repo.

I mean for sure Cargo is great for small hobby projects, but for the big complicated enterprise projects it's not really suitable. Even Google doesn't use Cargo in Fuchsia and vendors everything.

Re: Mitigating Memory Safety Issues in Open Source Software

#217
post #211
post #57

While rust certainly does a lot of things right, it is still a moving target with a relatively high velocity. There is a python library that recently switched to rust (partially) and now cannot be build on several platforms. This also means that very long-lived platforms will probably be forced to upgrade that library every half year or so in line with the development of rust. I'd say such an initiative needs a long-…

>There is a python library that recently switched to rust (partially) and now cannot be build on several platforms. Progress should not be held back for the rest of us because a few will get left behind. If you are running something so old that LLVM doesn't support it, upgrade. It's 2021.

I guarantee you that there is a device in your house that Rust does not target.

Re: Mitigating Memory Safety Issues in Open Source Software

#218
post #137

Earlier quoted context omitted.

I think you are missing the fact that the solutions are already in place for all of this. > One is the highly dynamic nature of cargo dependencies. libfoo might depend on a myriad of crates transitively and rust simply is too young to provide any experience in how long they will be available or supported. And no, it is generally not a good idea to update to new feature releases for security updates. This is something…

What I don't really like in cargo is its' overcentralized and author-centric approach. What if some of your dependencies relies on the crate, which author doesn't support anymore and doesn't even accept patches? You will basically have to maintain a fork either with a different name (because you can't push it to crates.io) or have a patched version which you also can't push and have to manually update every Cargo.tom…

I'm not entirely thrilled with the cargo solutions here, but when I compare them to the options in other languages I think they're adequate.

If you're making a small change, you use a [patch] section in the Cargo.toml for your workspace if you're using one, or the Cargo.toml for your binary/.so/.a if you're not, and it will cause your entire dependency tree to use your forked library. You don't need to fork the entire ecosystem as you suggest.

The [patch] works at the "workspace" level (and you generally should stick your entire complex system under one workspace), so if you use that feature properly for your "complex system" (keeping everything under one workspace), it is a one line change to replace the dependency for your entire system. If you use multiple, well, one per workspace that produces a binary/.so/.a.

Also, for big enterprise projects, I would assume you would use a private registry in the first place, which is apparently well supported (though I haven't used it). That's how the enterprise places I work at have dealt with python dependencies for instance (I haven't used rust in a enterprise).

I can sort of understand people trying to maintain LTS linux distros complaining that for their purposes this is a bit of a pain compared to C style shared libraries (because they need to modify a lot of rust workspaces)... but to be honest I think that's a question of their package management tooling not rust's. Rust provided the tools they need to make their custom tooling work. As a user the number of times shared libraries have caused me pain makes me think that this static linking is the superior method of packaging.

Re: Mitigating Memory Safety Issues in Open Source Software

#219
post #208

Earlier quoted context omitted.

It's not a matter of interest; if an embedded platform matters they should be willing to pay someone to port Rust.

…or they can just continue using C.

And not be surprised when open source maintainers don't go out of their way to continue supporting their poorly supported platform...

Re: Mitigating Memory Safety Issues in Open Source Software

#220

Earlier quoted context omitted.

D now has a prototype borrow checker implemented.

That's very cool to hear! As the ceator of D, how do you see the place of borrow checking in the ecosystem long term? Would you imagine most D code to be written against the borrow checker in the future, with transparent convenience for GC types? Or would it remain a somewhat niche feature for domains that can benefit?

The borrow checker in D can be used incrementally, like functional programming, on a function-by-function basis. It can be used where it makes sense to use it. (If only the GC is being used, the borrow checker isn't needed.) Being incremental, it won't require redesigning the program to make use of it.

I don't know how pervasive its use will become, but I expect its use will steadily increase.

Post reply on HN