Live data from Hacker News

No-Panic Rust: A Nice Technique for Systems Programming

blog.reverberate.org

11–20 of 143 posts

Re: No-Panic Rust: A Nice Technique for Systems Programming

#11
I've had an unpleasant amount of crashes with Rust software because people are way too quick to grab `panic!` as an out.

This was most shocking to me in some of the Rust code Mozilla had integrated into Firefox (the CSS styling code). There was some font cache shenanigans that was causing their font loading to work only semi-consistently, and that would outright crash this subsystem, and tofu-ify CJK text entirely as a result.

And the underlying panic was totally recoverable in theory if you looked at the call stack! Just people had decided to not Result-ify a bunch of falliable code.

Re: No-Panic Rust: A Nice Technique for Systems Programming

#12
post #3

This seems..absurd for a programming language with goals like Rust. Why isn't this a compiler option? Just set -nopanics and the compiler errors and flags anything which is pulling in a panic at the very least?

You can set panic: abort [1] if you don't want the unwinding mechanism. You still get a nice error message on panic, which causes the compiler to link in some formatting code from the standard library. I'm not sure if you can get rid of that.

On the same page are also the options for controlling debug assertions and overflow checks, which would get rid of the "panics in debug, but not release", if that behavior bugs you

1: https://doc.rust-lang.org/cargo/reference/profiles.html#pani...

Re: No-Panic Rust: A Nice Technique for Systems Programming

#13
post #2

This website makes by browser freeze... No idea why. Not able to read the article.

Same, the web view in my Android client crashed after a couple seconds.

I wonder if it's all the Godbolt iframes. Do you have the same problem on other pages, like https://blog.reverberate.org/2025/01/27/an-ode-to-header-fil... ?

Re: No-Panic Rust: A Nice Technique for Systems Programming

#14
post #3

This seems..absurd for a programming language with goals like Rust. Why isn't this a compiler option? Just set -nopanics and the compiler errors and flags anything which is pulling in a panic at the very least?

Well, if they did that, then people could expect/demand stability with regard to what scenarios get the checks/panics optimized out. This would be a bit of a burden for the Rust maintainers. It would effectively make the optimizer part of the language specification, and that's undesireable.

Re: No-Panic Rust: A Nice Technique for Systems Programming

#15

Earlier quoted context omitted.

Same, the web view in my Android client crashed after a couple seconds.

I wonder if it's all the Godbolt iframes. Do you have the same problem on other pages, like https://blog.reverberate.org/2025/01/27/an-ode-to-header-fil... ?

Other pages on the site work fine for me yeah. But the OP blog post is crashing my Android browser, like the other commenters have mentioned.

Re: No-Panic Rust: A Nice Technique for Systems Programming

#16
The approach at the end of declaring invariants to the compiler so the compiler can eliminate panics seems accidentally genius. You can now add the same invariants as panicking asserts at the end of each function, and the compiler will prove to you that your functions are upholding the invariants. And of course you can add more panicking asserts to show other claims to be true, all tested at compile time. You've basically built a little proof system.

Sure, Rust is hardly the first language to include something like that and adoption of such systems tends to be ... spotty. But if it was reliable enough and had a better interface (that preferably allowed the rest of your program to sill have panics) this might be very useful for writing correct software.

Re: No-Panic Rust: A Nice Technique for Systems Programming

#17
post #6
post #2

This website makes by browser freeze... No idea why. Not able to read the article.

Author here -- that is surprising. What browser/OS are you on? I haven't had anyone else report this problem before.

I’m seeing the same problem, the page crashes on Safari on iOS, saying a problem repeatedly occurred. Haven’t seen a webpage do that in quite a while.

Re: No-Panic Rust: A Nice Technique for Systems Programming

#18
post #11

I've had an unpleasant amount of crashes with Rust software because people are way too quick to grab `panic!` as an out. This was most shocking to me in some of the Rust code Mozilla had integrated into Firefox (the CSS styling code). There was some font cache shenanigans that was causing their font loading to work only semi-consistently, and that would outright crash this subsystem, and tofu-ify CJK text entirely as…

At least sources of panic! are easily greppable. Cutting corners on error handling is usually pretty obvious

Re: No-Panic Rust: A Nice Technique for Systems Programming

#19

This seems to obviate a lot of Rust's advantages (like a good std library). I wonder what it would take to write a nopanic-std library? Panics really seem bad for composability. And relying on the optimzer here seems like a fragile approach. (And how is there no -nopanic compiler flag?)

The standard library is slowly adding non-panicking options. The article shows some of them (like vec.push_within_capacity()) and ignores some others (vec.get_unchecked()). There is still a lot of work to do, but it is an area where a lot of work gets done. The issue is just that a) Rust is still a fairly young language, barely a decade old counting from 1.0 release, and b) Rust is really slow and methodical in adding anything to stdlib because of how hard/impossible it is to reverse bad decisions in the stdlib.

The same article written a couple years in the future would look very different

Re: No-Panic Rust: A Nice Technique for Systems Programming

#20
post #6

Earlier quoted context omitted.

Author here -- that is surprising. What browser/OS are you on? I haven't had anyone else report this problem before.

I’m seeing the same problem, the page crashes on Safari on iOS, saying a problem repeatedly occurred. Haven’t seen a webpage do that in quite a while.

Yep, same experience, same platform. I guess straight to reader mode, it is.

EDIT - shockingly, reader mode also fails completely after the page reloads itself

Post reply on HN