Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: On RFC-1236, behind the scenes of `catch_unwind`
Maybe zulip isn't quite the right place for asking generic questions so I'm also posting here, too.
Per RFC-1236:
- 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.- 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
orRc
) 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
🏷️ rust_feed