Comment

Comment by anderskaseorg

Yes, allowing this to execute would be very unsound:

    let lock = RwLock::new(Box::new(111));
    let r: &i32 = &**lock.read().unwrap(); // points to 111
    *lock.write().unwrap() = Box::new(222); // allocates a new Box and deallocates 111
    println!("{}", *r); // use after free

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton