Another ex-PVBM assert
[p5sagit/p5-mst-13.2.git] / t / op / threads.t
index e52a115..8907d80 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {
        exit 0;
      }
 
-     plan(9);
+     plan(10);
 }
 
 use strict;
@@ -143,4 +143,20 @@ EOI
 
 } # TODO
 
+# [perl #45053] Memory corruption with heavy module loading in threads
+#
+# run-time usage of newCONSTSUB (as done by the IO boot code) wasn't
+# thread-safe - got occasional coredumps or malloc corruption
+{
+    local $SIG{__WARN__} = sub {};   # Ignore any thread creation failure warnings
+    my @t;
+    for (1..100) {
+        my $thr = threads->create( sub { require IO });
+        last if !defined($thr);      # Probably ran out of memory
+        push(@t, $thr);
+    }
+    $_->join for @t;
+    ok(1, '[perl #45053]');
+}
+
 # EOF