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

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' => {} };

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

    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.

      I just tried using the versions you mentioned, and I still see the problem arising. I get the same results using another debian server with similar perl installation.

      I then tested against my other system running perl 5.8.5 and threads/shared 1.05/0.92 with normal behaviour

      I'm starting to think it's Dumper's fault.
        I just tried using the versions you mentioned, and I still see the problem arising.

        That is not good news. Please raise a perlbug against thread::shared immediately.

        I'm starting to think it's Dumper's fault.

        That's a distinct possibility, though the maintainers might argue that they should not be able to be the cause of such a problem.

        In the meantime, try using Data::Dump and see how you fare? (But please raise the perlbug report anyway, even if it alleviates your immediate problem!).


        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.
        Doesn't seem to be Dumper. I replaced it by some printf's and I still get the strange result. I think it may just be the way STDERR/OUT is handled on my system, and misinterpreting the output