archer has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I'm trying to use threads to enhance the speed of my program. But i get the following error "Free to wrong pool 142bbc0 not 346be0 during global destruction." when i run the script and the program gets terminated abruptly. I tried googling but wasnt able to get any idea on how to fix this issue.
use threads; use threads::shared; my @threads; for(my $index = 0; $index < scalar(@input_files); $index++) { push(@threads, threads->new(\&doProcessing, $input,$output)); + #$input and $output are the contents of input and output files } my @ReturnData; foreach my $thread (@threads) { push(@ReturnData,$thread->join()); }
Kindly provide ur ideas and help me resolve this issue.

Replies are listed 'Best First'.
Re: Free to wrong pool error while using thread
by BrowserUk (Patriarch) on Apr 05, 2012 at 05:43 UTC

    The error invariably means you are doing something wrong, but there are a variety of things that can cause it.

    If you post your code, we will probably be able to identify it for you.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re: Free to wrong pool error while using thread
by dave_the_m (Monsignor) on Apr 05, 2012 at 15:28 UTC
    There were many bugs in the threading code of older versions of perl, which have generally been fixed now. So I would recommend you try it with the newest version of perl you can (e.g. 5.14.2) and see if the problem goes away.

    What version of perl are you using, and on what platform?

    Alternatively, if you use any modules that use XS rather than being pure perl, then the bug may reside in that module. Try if possible to reduce your problem to the smallest complete program that has as few external dependencies as possible.

    Dave.

Re: Free to wrong pool error while using thread
by Anonymous Monk on Apr 05, 2012 at 18:56 UTC
    Are each of the threads attempting to share the content of "$input" and "$output" and if so, are these data structures properly declared as shared?