about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-04-23 08:43:06 +0200
committerRalf Jung <post@ralfj.de>2024-04-25 09:51:15 +0200
commitea9cff254f2e363a30fcd6f887347f05a76a0f70 (patch)
tree43109c3661cfc4076746eba48bb375b8e1251984
parentf38dba69b18a8ce593272ea3c2369c4274d8837b (diff)
downloadrust-ea9cff254f2e363a30fcd6f887347f05a76a0f70.tar.gz
rust-ea9cff254f2e363a30fcd6f887347f05a76a0f70.zip
add a test for the TLS memory leak
-rw-r--r--src/tools/miri/tests/many-seeds/tls-leak.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tools/miri/tests/many-seeds/tls-leak.rs b/src/tools/miri/tests/many-seeds/tls-leak.rs
new file mode 100644
index 00000000000..70a506958d1
--- /dev/null
+++ b/src/tools/miri/tests/many-seeds/tls-leak.rs
@@ -0,0 +1,13 @@
+//! Regression test for <https://github.com/rust-lang/rust/issues/123583>.
+use std::thread;
+
+pub(crate) fn with_thread_local() {
+    thread_local! { static X: Box<u8> = Box::new(0); }
+    X.with(|_x| {})
+}
+
+fn main() {
+    let j2 = thread::spawn(with_thread_local);
+    with_thread_local();
+    j2.join().unwrap();
+}