-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)C-bugCategory: This is a bug.Category: This is a bug.O-androidOperating system: AndroidOperating system: AndroidO-linuxOperating system: LinuxOperating system: LinuxO-muslTarget: The musl libcTarget: The musl libc
Description
Simplified testcase:
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("Foo dtor");
}
}
thread_local!(static FOO: Foo = Foo);
fn main() {
FOO.with(|_| {});
}
This should print Foo dtor
, but prints nothing on some targets:
- musl (e.g. i686-unknown-linux-musl, x86_64-unknown-linux-musl)
- android (e.g. arm-linux-androideabi)
- Linux with glibc before 2.18
- Maybe more?
Here's a more complicated testcase that also involves initializing a destructor while destructors are being run; ideally this will be added to the test suite at some point:
struct Bar;
impl Drop for Bar {
fn drop(&mut self) {
println!("Bar dtor");
}
}
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("Foo dtor");
// We initialize another thread-local inside the dtor, which is an interesting corner case.
thread_local!(static BAR: Bar = Bar);
BAR.with(|_| {});
}
}
thread_local!(static FOO: Foo = Foo);
fn main() {
FOO.with(|_| {});
}
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-thread-localsArea: Thread local storage (TLS)Area: Thread local storage (TLS)C-bugCategory: This is a bug.Category: This is a bug.O-androidOperating system: AndroidOperating system: AndroidO-linuxOperating system: LinuxOperating system: LinuxO-muslTarget: The musl libcTarget: The musl libc