On RFC-1236, behind the scenes of `catch_unwind`

⚓ Rust    📅 2025-07-21    👤 surdeus    👁️ 1      

surdeus

Maybe zulip isn't quite the right place for asking generic questions so I'm also posting here, too.

Per RFC-1236:

  1. Single-threaded types with interior mutability, such as RefCell, allow for sharing data across stack frames such that a broken invariant could eventually be observed.
  2. Whenever a thread panics, the destructors for its stack variables will be run as the thread unwinds. Destructors may have access to data which was also accessible lower on the stack (such as through RefCell or Rc) which has a broken invariant, and the destructor may then witness this.

My confusion is that why are Rc and RefCell explicitly mentioned here? References point to something in the caller (or ancestor callers), i.e. those on the lower part of the call stack, all the time, no? So why should destructors in the unwind code care about the difference between those data behind generic references and those behind types with interior mutability?

1 post - 1 participant

Read full topic

🏷️ rust_feed