Reset rustc's scoped TLS state during unwinding.

2af39b7
Opened by Eduard-Mihai Burtescu at 2020-04-20 23:06:33

This should only happen in the event of an ICE, but right now, if a Drop implementation (for e.g. a field in Session) would try to access, say, the TLS_TCX, it would use-after-free the global TyCtxt.

  1. Isn't this disallowed by the LocalKey requirement that a key's "initializer cannot recursively depend on itself"? To be fair, that wording was only added to the documentation recently.

    Joshua Liebow-Feeser at 2018-01-07 08:40:34

  2. @joshlf We use thread_local to hold a raw pointer in a Cell in order to do scoped TLS, the actual usage of LocalKey itself is trivial, it's what we do with the pointer that matters.

    Eduard-Mihai Burtescu at 2018-01-07 12:56:15