Subject: | Test::Builder END block issue when with threads and forks |
Date: | Wed, 17 May 2006 10:08:06 -0700 |
To: | bug-test-simple [...] rt.cpan.org |
From: | "Michael G Schwern" <schwern [...] gmail.com> |
Show quoted text
--------- Forwarded message ----------
From: Eric Rybski <rybskej@yahoo.com>
Date: May 16, 2006 2:21 PM
Subject: Test::Builder END block issue when with threads and forks
To: schwern@pobox.com
Michael,
In Test::Builder 0.32, subroutine _ending, the
$self->_sanity_check();
should come after the determination if this is a forked copy, as it causes
problems with test scripts that mix threads and forks.
Warnings get randomly thrown otherwise, due to the fact that the shared
variables within _sanity_check() may be modified by another thread while in
this end block (a potential race condition), causing the 'Somehow you got a
different number of results than tests ran!' error to be thrown at random
times
while running a test script that uses Test::Builder.
The diff is at the end of this message. Hopefully this will make it into a
future release of your module!
Thanks,
Eric Rybski
--- /usr/local/lib/perl5/5.8.7/Test/Builder.pm 2006-04-29 19:41:
18.419994000
-0400
+++ /usr/local/lib/perl5/5.8.7/Test/Builder.pm.threadfork_patch 2006-05-16
17:13:43.550005000 -0400
@@ -1589,8 +1589,6 @@
sub _ending {
my $self = shift;
- $self->_sanity_check();
-
# Don't bother with an ending if this is a forked copy. Only the
parent
# should do the ending.
# Exit if plan() was never called. This is so "require Test::Simple"
@@ -1605,6 +1603,8 @@
return;
}
+ $self->_sanity_check();
+