5 ms·
Linus's initial reaction: https://lkml.org/lkml/2021/4/14/1099 https://lkml.org/lkml/2021/4/14/1099 I am pleased that these are all addressable things. We'll s
by steveklabnik 6y ago
Linus's initial reaction: https://lkml.org/lkml/2021/4/14/1099 https://lkml.org/lkml/2021/4/14/1099
I am pleased that these are all addressable things. We'll see!
- joseluisq 6y agoYep, BTW looking forward https://lkml.org/lkml/2021/4/14/1105 https://lkml.org/lkml/2021/4/14/1105 those kind of 'real piece of code' that pleases Linus :)
- xiphias2 6y agoThey are not just addressable, but actually make Rust itself a better systems programming language.
- steveklabnik 6y agoYes, I specifically would really like to see what Josh is talking about here happen: https://lore.kernel.org/lkml/YHdSATy9am21Tj4Z@localhost/ https://lore.kernel.org/lkml/YHdSATy9am21Tj4Z@localhost/ It's kind of a funny space; right now Rust handily gives you "no allocations" (this is where I live) or "infallible + fallible allocations" (this is alloc/std by default) but not "only fallible allocations". This sort of thing is basically filling out the quadrant of options.
- hathawsh 6y agoThe most impressive part is that it's actually conceivable to implement such deep changes without a major version bump in Rust. (I hope so anyway!)
- steveklabnik 6y agoYup, it is. If this plan linked above were to be implemented, what would happen is that you would get the same behaviors by default, but with a new setting, you'd get some APIs removed. That's backwards compatible.
- tetha 6y agoI was thinking that when reading the exchanges. This is a really good interaction. Linus and the kernel have strong requirements for good reasons, and the rust teams are trying to address them in useful ways. Rust in the kernel is not a simple thing, but I think both rust and the kernel will benefit.
- dbrgn 6y agoThere's a Rust RFC and Linus doesn't hate it. Great news!
- joseluisq 6y agoYeah! Even he kind of appreciates one of my favorite Rust features. > So "Result<T, E>" is basically the way to go, and if the standard Rust library alloc() model is based on "panic!" then that kind of model must simply not be used in the kernel. https://lkml.org/lkml/2021/4/14/1131 https://lkml.org/lkml/2021/4/14/1131
- yazaddaruvala 6y agoDo you think a more ergonomic `#[no_panic]`[0] would require Rust wait for an entire effect system, or be valuable enough to add to the compiler as a one-off? [0] https://github.com/dtolnay/no-panic https://github.com/dtolnay/no-panic
- steveklabnik 6y agoI am not sure.
- pedrocr 6y agoEven for normal user space code having a way to detect panic at compile time and abort compilation would be great. Ideally together with a way to wrap functions that do panic by catching it and throwing an error instead so the panic infrastructure can still be used. I've sketched that out on HN the other day: https://news.ycombinator.com/item?id=26191644 https://news.ycombinator.com/item?id=26191644
- gpm 6y agoThis exists, provided you compile with the (default) unwinding panics https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
- estebank 6y agoThat is still something that happens at runtime, not compile-time. What the kernel would need is not only for the fallible alloc APIs (like Box::try_new) to be expanded to cover all their needs, but also to be able to remove the ability to use the infallible/panicky ones (like Box::new) to ensure, at compile time, that panic will never be called.
- chrismorgan 6y ago> Note that this function may not catch all panics in Rust. A panic in Rust is not always implemented via unwinding, but can be implemented by aborting the process as well. This function only catches unwinding panics, not those that abort the process. The most notable way this can go wrong in pure Rust code is that panic-while-panicking aborts. So you have to be careful that your destructor can never panic.
- nynx 6y agoIt's already kind of possible to statically prevent all panics: https://crates.io/crates/no-panics-whatsoever https://crates.io/crates/no-panics-whatsoever. It's pretty hacky, but it works on no_std.
- yagizdegirmenci 6y agoLinus addresses the RFC 2116[1] of Rust which aims to add support for fallible allocations to the standard collection APIs. This RFC is accepted and implemented. See the Josh's answer[2]. [1]: https://github.com/rust-lang/rfcs/blob/master/text/2116-alloc-me-maybe.md https://github.com/rust-lang/rfcs/blob/master/text/2116-allo... [2]: https://lore.kernel.org/lkml/YHdSATy9am21Tj4Z@localhost/ https://lore.kernel.org/lkml/YHdSATy9am21Tj4Z@localhost/
- JoshTriplett 6y agoRFC 2116 addresses part of the issue. The other part of the problem would be to support disabling the non-fallible APIs at compile time. Also, RFC 2116 assumes that it's sufficient to provide (for instance) Vec::try_reserve, and require callers to always call that before calling anything that might expand the Vec. That wouldn't eliminate the runtime panics. It might be necessary to go a step further, and actually provide fallible versions of individual Vec methods. (Or there may be other potential solutions.)
- Ericson2314 6y agoYeah `try_reserve` is ~~racy and~~ (edit, strikethrough) awkward to use. And having a bunch of a panics which "should" be dead code because of the proceeding `try_reserve` at best adds a bunch of noise burdening static analysis. A bunch of us, anticipating a reaction like Linus' have been arguing that we need `try_` versions of everything and* a way to prevent the other ones from being used. (Cargo features?) I sincerely hope we finally get that.
- caslon 6y agoIt's unfortunate that this might happen. Kernel compilation times were starting to become so reasonable!
- hulitu 6y agoThis is the problem with SW developers: when something starts working they want to "improve" it until it doesn't work. See firefox for a nice example (it is so sloooow). (no i do not have an SSD but earlier it was reasonable. Now the change to rust is making it slower without any visible improvement in security- still have to update every couple of weeks because of CVEs)
- caslon 6y agoNo, Rust didn't actually make it slower to run. It's likely it made it a bit faster; the code quality in Firefox isn't great. It just makes things slower to compile and less portable.
- easton 6y agoWhat does NAK mean?
- momothereal 6y agoThe opposite of ACK (Acknowledged) in many protocols. Basically Rejected.
- diamondo25 6y agoUsually Not Acknowledged.
- gnull 6y ago"Not Acknowledged", I believe [1]. [1]: https://www.kernel.org/doc/html/v4.15/process/stable-kernel-rules.html https://www.kernel.org/doc/html/v4.15/process/stable-kernel-...
- __david__ 6y agoNegatively Acknowledged, I would say. “Not acknowledged” implies no response rather than a negative response, IMO.
- deleted 6y ago[deleted]
- wahern 6y agoIt comes from the ASCII C0 [transmission] control code NAK, which means "negative acknowledgment"--something was wrong with the last transmitted data block or command, or the reception of it. As opposed to "ACK", which means a block or command was successfully received and accepted. In the original 1963 standard the mnemonic was "ERR", but changed to "NAK" for the 1965 standard. See https://en.wikipedia.org/wiki/C0_and_C1_control_codes https://en.wikipedia.org/wiki/C0_and_C1_control_codes and https://en.wikipedia.org/wiki/ASCII https://en.wikipedia.org/wiki/ASCII In programmer lingo it can means something similar to the original meaning--rejecting a request for faultiness or incompleteness--or it can mean something more like, "no"--answering in the negative.
- thayne 6y agoCould a custom panic handler ( https://doc.rust-lang.org/nomicon/panic-handler.html https://doc.rust-lang.org/nomicon/panic-handler.html) be used to handle allocation or other panics in a more graceful way?
- steveklabnik 6y agoIn theory maybe but in practice I don't think you'd want that.
- flashgordon 6y agoIs it me (and have I been hiding/asleep under a rock for a long time) or is Linus' tone vastly (and pleasantly) different from what his previous persona is known to be? I actually loved (I mean really loved) reading the response as it not only was encouraging but also highly respectful and almost glowing with a trained sort of nuance! Just wow!
- eska 6y agoNah. He took a break to reform himself, but has posted abusive messages since then again here and there.
- IntelMiner 6y agoSuch as?
- dn3500 6y agoHe's really changed. There is a subreddit /r/linusrants that documents his rants. In the last year there have been 9 posts, but most of those are reposts from previous years or not really rants or aimed at technologies, not people. Three years ago there were 27 posts.
- skinkestek 6y agoAnd what makes this even more impressive is that he managed to do it despite being - in manys eyes - a very nice and reasonable person to start with, it wasn't like everything was falling apart around him and everyone was leaving their jobs as maintainers AFAIK, he just decided it would be better for the project if he left this part of his personality behind.
- galgalesh 6y agoIn case you did not know this; he took a break a while back to work on his empathy and communication skills.
- steveklabnik 6y agoI don't read the lkml enough to truly know, but in 2018 he made a public apology and (IIRC) took some time off to go work on his behavior. So maybe that's it! I agree that I found his messages here to be quite pleasant.
- mlindner 6y agoI'm confused why this even came up? Why can't the panics just be caught at the driver interface to the kernel and kill off/unload the driver on panic?