6 use Config qw/%Config/;
9 if (!$Config{useithreads}) {
12 plan(skip_all => 'This perl wasn\'t built to support threads');
21 require autovivification;
22 if (autovivification::A_THREADSAFE()) {
24 defined and diag "Using threads $_" for $threads::VERSION;
26 plan skip_all => 'This autovivification isn\'t thread safe';
33 my $SystemRoot = $ENV{SystemRoot};
35 $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
37 system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
42 skip 'Fails on 5.8.2 and lower' => 1 if $] <= 5.008002;
44 my $status = run_perl <<' RUN';
47 $code -= threads->create(sub {
48 eval q{no autovivification; my $x; my $y = $x->{foo}; $x};
49 return defined($x) ? 0 : 1;
51 $code -= defined(eval q{my $x; my $y = $x->{foo}; $x}) ? 2 : 0;
52 $code -= defined(eval q{no autovivification; my $x; my $y = $x->{foo}; $x})
56 is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';