Skip to content

Commit 7b2163d

Browse files
committed
auto merge of #8303 : brson/rust/tls-magic-wtf, r=brson
2 parents 4fdd720 + 1c1add2 commit 7b2163d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/libstd/rt/task.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ impl Task {
228228
_ => ()
229229
}
230230

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

0 commit comments

Comments
 (0)