Open eddyb opened 6 years ago
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.
@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.
This should only happen in the event of an ICE, but right now, if a
Drop
implementation (for e.g. a field inSession
) would try to access, say, theTLS_TCX
, it would use-after-free the globalTyCtxt
.