Linus Torvalds on memory allocation and Rust

I think this is hugely relevant to Zig. It’s as if Andrew Kelley had a crystal ball!

And if the panic situation is some fundamental “this is what the Rust
compiler does for internal allocation failures”, then I think it needs
more than just kernel wrapper work - it needs the Rust compiler to be
fixed.

https://lkml.org/lkml/2021/4/14/1099

Discussion: https://www.reddit.com/r/rust/comments/ms2nl7/linus_torvalds_concerns_about_panics_in_rust_code/?%24deep_link=true&correlation_id=a9ff3b8d-362d-4f28-b44a-b82a4e3da3a5&post_fullname=t3_ms2nl7&post_index=3&ref=email_digest&ref_campaign=email_digest&ref_source=email&utm_content=post_title&%243p=e_as&_branch_match_id=865216565048290772

1 Like

Indeed. But I think that the tide is sufficiently leaning on this direction that a solution can be found which will satisfy Torvalds.

However, I do think that for low level code Zig went in a slightly better direction on this issue. If it were (hypothetically) Zig, and not Rust, being discussed then the solution would be simple: Define an allocator that cannot panic and enforce it’s usage in all kernel code :slight_smile:

5 Likes