about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/thread-local/spawn-hook-atexit.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/thread-local/spawn-hook-atexit.rs b/tests/ui/thread-local/spawn-hook-atexit.rs
new file mode 100644
index 00000000000..cc517e8fa4c
--- /dev/null
+++ b/tests/ui/thread-local/spawn-hook-atexit.rs
@@ -0,0 +1,22 @@
+// Regression test for https://github.com/rust-lang/rust/issues/138696
+//@ run-pass
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    std::thread::spawn(|| {
+        unsafe { libc::atexit(spawn_in_atexit) };
+    })
+    .join()
+    .unwrap();
+}
+
+extern "C" fn spawn_in_atexit() {
+    std::thread::spawn(|| {
+        println!("Thread spawned in atexit");
+    })
+    .join()
+    .unwrap();
+}