|
Packit |
14c646 |
|
|
Packit |
14c646 |
# as of 2.09 on win32 Storable w/threads dies with "free to wrong
|
|
Packit |
14c646 |
# pool" since it uses the same context for different threads. since
|
|
Packit |
14c646 |
# win32 perl implementation allocates a different memory pool for each
|
|
Packit |
14c646 |
# thread using the a memory pool from one thread to allocate memory
|
|
Packit |
14c646 |
# for another thread makes win32 perl very unhappy
|
|
Packit |
14c646 |
#
|
|
Packit |
14c646 |
# but the problem exists everywhere, not only on win32 perl , it's
|
|
Packit |
14c646 |
# just hard to catch it deterministically - since the same context is
|
|
Packit |
14c646 |
# used if two or more threads happen to change the state of the
|
|
Packit |
14c646 |
# context in the middle of the operation, and those operations aren't
|
|
Packit |
14c646 |
# atomic per thread, bad things including data loss and corrupted data
|
|
Packit |
14c646 |
# can happen.
|
|
Packit |
14c646 |
#
|
|
Packit |
14c646 |
# this has been solved in 2.10 by adding a Storable::CLONE which calls
|
|
Packit |
14c646 |
# Storable::init_perinterp() to create a new context for each new
|
|
Packit |
14c646 |
# thread when it starts
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
sub BEGIN {
|
|
Packit |
14c646 |
unshift @INC, 't';
|
|
Packit |
14c646 |
unshift @INC, 't/compat' if $] < 5.006002;
|
|
Packit |
14c646 |
require Config; import Config;
|
|
Packit |
14c646 |
if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
|
|
Packit |
14c646 |
print "1..0 # Skip: Storable was not built\n";
|
|
Packit |
14c646 |
exit 0;
|
|
Packit |
14c646 |
}
|
|
Packit |
14c646 |
unless ($Config{'useithreads'} and eval { require threads; 1 }) {
|
|
Packit |
14c646 |
print "1..0 # Skip: no threads\n";
|
|
Packit |
14c646 |
exit 0;
|
|
Packit |
14c646 |
}
|
|
Packit |
14c646 |
if ($] eq "5.008" || $] eq "5.010000") {
|
|
Packit |
14c646 |
print "1..0 # Skip: threads unreliable in perl-$]\n";
|
|
Packit |
14c646 |
exit 0;
|
|
Packit |
14c646 |
}
|
|
Packit |
14c646 |
# - is \W, so can't use \b at start. Negative look ahead and look behind
|
|
Packit |
14c646 |
# works at start/end of string, or where preceded/followed by spaces
|
|
Packit |
14c646 |
if ($] == 5.008002 and eval q{ $Config{'ccflags'} =~ /(?
|
|
Packit |
14c646 |
# Bug caused by change 21610, fixed by change 21849
|
|
Packit |
14c646 |
print "1..0 # Skip: tickles bug in threads combined with -DDEBUGGING on 5.8.2\n";
|
|
Packit |
14c646 |
exit 0;
|
|
Packit |
14c646 |
}
|
|
Packit |
14c646 |
}
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
use Test::More;
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
use strict;
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
use threads;
|
|
Packit |
14c646 |
use Storable qw(nfreeze);
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
plan tests => 2;
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
threads->new(\&sub1;;
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
$_->join() for threads->list();
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
ok 1;
|
|
Packit |
14c646 |
|
|
Packit |
14c646 |
sub sub1 {
|
|
Packit |
14c646 |
nfreeze {};
|
|
Packit |
14c646 |
ok 1;
|
|
Packit |
14c646 |
}
|