#!/usr/bin/perl use threads; use Thread::Semaphore; sub bad{ sub mysub{ print "my sub : $1 $2\n"; } $a="Hi there and hi there.\n"; $a =~ s/(\w+ \w+)(?{mysub();})//gi ; } sub mythread { print "begin\n"; print "end\n"; } bad(); my $thr = threads->new(\&mythread); @r=$thr ->join(); __END__ #### ./testthread.pl my sub : Hi there my sub : and hi begin end *** glibc detected *** /usr/bin/perl: double free or corruption (!prev): 0x08271ce8 ***