]> git.lizzy.rs Git - rust.git/commitdiff
std::rt: Use magic to make TLS work from annihilated boxes. #8302
authorBrian Anderson <banderson@mozilla.com>
Mon, 5 Aug 2013 07:32:46 +0000 (00:32 -0700)
committerBrian Anderson <banderson@mozilla.com>
Mon, 5 Aug 2013 07:36:02 +0000 (00:36 -0700)
src/libstd/rt/task.rs

index ffe9f118b477cbe90548dddd485092122776c783..cb949edd7bb4a76e1ca00e02e12baa9bfd1a8ceb 100644 (file)
@@ -228,6 +228,19 @@ pub fn run(&mut self, f: &fn()) {
                     _ => ()
                 }
 
+                // 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(); }
             }