diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index ffe9f118b47..cb949edd7bb 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -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(); } }