in reply to Re^11: does threads (still) memleak?
in thread does threads (still) memleak?

Regarding the corrected version of the code, I get different results randomly:
$ ~/perl/recycleshare3 2$VAR1 = { 'a' => {} }; 1$VAR1 = { 'a' => {}, 'b' => {}, 'a' => {}, 'b' => {} }; $ ~/perl/recycleshare3 1$VAR1 = { 'a' => {}, 'b' => {} }; 2$VAR1 = { 'a' => {}, 'b' => {} };

Replies are listed 'Best First'.
Re^13: does threads (still) memleak?
by BrowserUk (Patriarch) on Nov 28, 2008 at 13:30 UTC

    Sorry, but I would have to say that the first version of the output you've posted above is impossible. It suggests that you have managed to create a hash with duplicate keys--and that is impossible!

    You're going to have to post the code that you're using, along with the versions of Perl/threads/threads::shared. Nether version of the 'corrected' code I posted could ever produce that first output barring some catastrophic corruption.


    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 code I used is pasted here:
      #!/usr/bin/perl use warnings; use strict; use threads; use threads::shared; use Data::Dumper; use Config; printf "perl: %s\n", $Config{version}; printf "gcc: %s\n", $Config{gccversion}; printf "threads: %s\n", $threads::VERSION; printf "threads::shared: %s\n", $threads::shared::VERSION; my %hash :shared; sub sub1 { sleep 1; print STDERR threads->tid(); print STDERR Dumper \%hash; } $hash{a} = &share({}); my $th1 = threads->new('sub1'); $hash{b} = &share({}); my $th2 = threads->new('sub1'); $th1->join(); $th2->join();
      I just reproduced the result:
      $ ~/perl/recycleshare3 perl: 5.10.0 gcc: 4.3.2 threads: 1.67 threads::shared: 1.14 1$VAR1 = { 'a' => {}, 'b' => {} }; 2$VAR1 = { 'a' => {}, 'b' => {} }; $ ~/perl/recycleshare3 perl: 5.10.0 gcc: 4.3.2 threads: 1.67 threads::shared: 1.14 2$VAR1 = { 'a' => {} }; 1$VAR1 = { 'a' => {}, 'b' => {}, 'a' => {}, 'b' => {} };

        Hm. I cannot even begin to imagine the circumstances that would allow that (duplicate hash keys) to happen. More importantly, how it could possibly get past regression testing into the wild. No matter. The versions you are using are well down level, and anyone can make a mistake.

        Upgrade! Get the latest cpan versions of both threads and threads::shared--1.71/1.27--respectively. If you can reproduce the results once you've done that, you need to raise a perlbug immediately. Hopefully this is just the result of an unfortunate mix of intermediate releases.


        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.