#!/usr/bin/perl -w
# Simulate "Free to wrong pool" crash from Telnet.pm, line 1987
# This program crashes with Perl 5.8.4/5.8.5 (on multi-cpu boxes only).
use strict;
use threads;
sub do_one_thread {
my $kid = shift;
warn "kid $kid before local\n";
for my $j (1..99999) {
my @warns;
{ local $^W = 1;
local $SIG{"__WARN__"} = sub { push @warns, @_ };
}
}
warn "kid $kid after local, sleeping 1\n";
sleep(1);
warn "kid $kid exit\n";
}
sub do_threads {
my $nthreads = shift;
my @kids = ();
for my $i (0..$nthreads-1) {
my $t = threads->new(\&do_one_thread, $i);
warn "parent $$: continue\n";
push(@kids, $t);
}
for my $t (@kids) {
warn "parent $$: waiting for join\n";
$t->join();
warn "parent $$: thread exited\n";
}
}
do_threads(2);
####
local $SIG{"__WARN__"} = sub { push @warns, @_ };
##
##
local $SIG{"__WARN__"} = eval <<'CLOSURE_HACK';
sub { push @warns, @_ }
CLOSURE_HACK