Subject: | Test::More not thread safe due to perl sort bug |
Test-Simple-0.47. perl version 5.8.4.
As described in perl bug #30333 "threads sort crashes with sort
subroutine (but not with sort block)" using sort subroutines is
not thread safe.
Because this perl bug presumably goes way back to many earlier perl
versions, it seems best to work around it in Test/More.pm.
I did a search of all perl core code and the only place that
uses a sort subroutine is Test/More.pm.
In More.pm, the _bogus_sort subroutine is used in only two places
(both as a sort subroutine). The attached patch inlines _bogus_sort
as a sort block to work around perl bug #30333.
/-\
--- More.pm 2004-06-29 13:27:05.000000000 +1000
+++ More.pm.orig 2004-06-29 13:25:24.000000000 +1000
@@ -1117,15 +1117,14 @@
# We must make sure that references are treated neutrally. It really
# doesn't matter how we sort them, as long as both arrays are sorted
# with the same algorithm.
-# Inlined _bogus_sort twice in eq_set below to work around perl threading bug #30333.
-# sub _bogus_sort { local $^W = 0; ref $a ? 0 : $a cmp $b }
+sub _bogus_sort { local $^W = 0; ref $a ? 0 : $a cmp $b }
sub eq_set {
my($a1, $a2) = @_;
return 0 unless @$a1 == @$a2;
# There's faster ways to do this, but this is easiest.
- return eq_array( [sort { local $^W = 0; ref $a ? 0 : $a cmp $b } @$a1], [sort { local $^W = 0; ref $a ? 0 : $a cmp $b } @$a2] );
+ return eq_array( [sort _bogus_sort @$a1], [sort _bogus_sort @$a2] );
}
=back