2 ms·
I was typing a comment about how Rust wouldn't have made a difference for the race condition, but after reading through it again to be sure i'm now on the side
by athrowaway3z 5y ago
I was typing a comment about how Rust wouldn't have made a difference for the race condition, but after reading through it again to be sure i'm now on the side that Rust would have errored on the original bug.
spin_lock_irq(&tty->ctrl_lock);
put_pid(real_tty->pgrp);
real_tty->pgrp = get_pid(pgrp);
spin_unlock_irq(&tty->ctrl_lock);
rustifying this would be
let mut tty_lock = tty.ctrl_lock();
put_pid(real_tty);
real_tty.pgrp = get_pid(pgrp);
std::mem::drop(tty_lock);
Which would give an error that you are not allowed to mutate real_tty.pgrp.