1
Fork 0

std::rt: Use magic to make TLS work from annihilated boxes. #8302

This commit is contained in:
Brian Anderson 2013-08-05 00:32:46 -07:00
parent 83d2a0431c
commit 1c1add23f6

View file

@ -228,6 +228,19 @@ impl Task {
_ => ()
}
// FIXME #8302: Dear diary. I'm so tired and confused.
// There's some interaction in rustc between the box
// annihilator and the TLS dtor by which TLS is
// accessed from annihilated box dtors *after* TLS is
// destroyed. Somehow setting TLS back to null, as the
// old runtime did, makes this work, but I don't currently
// understand how. I would expect that, if the annihilator
// reinvokes TLS while TLS is uninitialized, that
// TLS would be reinitialized but never destroyed,
// but somehow this works. I have no idea what's going
// on but this seems to make things magically work. FML.
self.storage = LocalStorage(ptr::null(), None);
// Destroy remaining boxes. Also may run user dtors.
unsafe { cleanup::annihilate(); }
}