Wedson Almeida Filho is a Microsoft engineer who has been prolific in his contributions to the Rust for the Linux kernel code over the past several years. Wedson has worked on many Rust Linux kernel features and even did a experimental EXT2 file-system driver port to Rust. But he’s had enough and is now stepping away from the Rust for Linux efforts.

From Wedon’s post on the kernel mailing list:

I am retiring from the project. After almost 4 years, I find myself lacking the energy and enthusiasm I once had to respond to some of the nontechnical nonsense, so it’s best to leave it up to those who still have it in them.

I truly believe the future of kernels is with memory-safe languages. I am no visionary but if Linux doesn’t internalize this, I’m afraid some other kernel will do to it what it did to Unix.

Lastly, I’ll leave a small, 3min 30s, sample for context here: https://youtu.be/WiPp9YEBV0Q?t=1529 – and to reiterate, no one is trying force anyone else to learn Rust nor prevent refactorings of C code."

  • witx@lemmy.sdf.org
    link
    fedilink
    arrow-up
    8
    ·
    4 months ago

    The difference is that now you have a scope of where the memory unsafe code might be(unsafe keyword) and you look there instead of all the C code.

    • qqq@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      edit-2
      4 months ago

      I agree and think that should be helpful, but I hesitate to say how much easier that actually makes writing sound unsafe code. I’d think most experienced C developers also implicitly know when they’re doing unsafe things, with or without an unsafe block in the language – although I think the explicit unsafe should likely help code reviewers and tired developers.

      It is possible to write highly unsafe code in Rust while each individual unsafe block appears sound. As a simple example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6a1428d9cae5b9343b464709573648b4 [1] Run that on Debug and Release builds. Notice the output is different? Don’t take that example as some sort of difficult case, you wouldn’t write this code, but the concepts in it are a bit worrisome. That code is a silly example, but each individual unsafe block appears sound when trying to reason only within the block. There is unsafe behavior happening outside of the unsafe blocks (the do_some_things function should raise eyebrows), and the function we ultimately end up in has no idea something unsafe has happened.

      Unsafe code in Rust is not easy, and to some extent it breaks abstractions (maybe pointers in general break abstractions to some extent?). noaliases in that playground code rightly assumes you can’t have a &ref and &mut ref to the same thing, that’s undefined behavior in Rust. Yet to understand the cause of that bug you have to look at all function calls on the way, just as you would have to in C, and one of the biggest issues in the code exists outside of an unsafe block.

      [1]: If you don’t want to click that link or it breaks, here is the code:

      fn uhoh() {
          let val = 9;
          let val_ptr: *const usize = &val;
          do_some_things(val_ptr);
          println!("{}", val);
      }
      
      fn do_some_things(val: *const usize) {
          let valref = unsafe { val.as_ref().unwrap() };
          let mut_ptr: *mut usize = val as *mut usize;
          do_some_other_things(mut_ptr, valref);
      }
      
      fn do_some_other_things(val: *mut usize, normalref: &usize) {
          let mutref = unsafe { val.as_mut().unwrap() };
          noaliases(normalref, mutref);
      }
      
      fn noaliases(input: &usize, output: &mut usize) {
          if *input < 10 {
              *output = 15;
          }
          if *input > 10 {
              *output = 5;
          }
      }
      
      fn main() {
          uhoh();
      }