14 comments
@niklaskorz why should it be considered unsafe? Just because memory is not reclaimed does not lead to undefined behavior. @niklaskorz If "safe" equals "not crashing", then memory leaks *are* safe to a certain point. That is, no NULL pointer deference, no access to memory after it is freed, no access outside object bounds, etc. @christophberger @matze Semantically speaking I agree, but from a practical point of view, I always feel like there should be some kind of additional "are you sure you want to do this?" for functions like Box::leak. Also it is probably unrelated to the issues Zed is experiencing, I can imagine the problem lies somewhere in their integration of language servers but also I don't want to dig so I'll just keep to vscode for now. @niklaskorz @matze I guess memory leaks are hard to catch at language level. The compiler cannot tell whether memory that's still referenced continues to be used. I also moved from Zed back to VSCodium, but for a different reason: I miss several features I'm used to, so I decided to switch back and keep watching Zed's evolution. Leaked memory is technically sound :) just inconvenient. Same goes for deadlocks as well. In rust there are only few ways one can leak memory. Some cases are explicit (.leak() method). The usual case is having 'std::sync::Arc' (or Rc) forming cycles. I'd do a 'grep Arc src/' to get an idea about where deadlocks happen. But its a big project. @niklaskorz True story on both counts. I do wonder if this particular case is not from the Zed editor's own Rust code but from one of the external tools it runs behind the scenes. (You do know Zed silently downloads and runs 3rd party binaries including an entire nodejs, right?) @alerque This particular case happened while working on nixpkgs. I use the same language server (nixd) on Zed and vscode. The latter does not experience such a massive amount of memory usage. @kdwarn @niklaskorz Opening the Rustlings project in Helix only takes 27MiB. Software can be efficient :) @niklaskorz Wow, this macOS pop-up is nice. I would like to have something like that on Linux instead of the entire system freezing up for a potentially long amount of time (especially if there is a swap partition) and then randomly killing processes until the system works again. @FSMaxB It does freeze quite a bit, but I somehow managed to take the screenshot inbetween. Also I think macOS has a very generous size limit for swapfile so as long as there's space on disk... @niklaskorz @niklaskorz because it's not. Memory leak cannot cause RCE, or DoS. It's just a performance bug, but not safety issue |
@niklaskorz to be fair, they do mention it in the book sooo
but yeah I caught myself believing that at first too tbh