On Mon, May 5, 2008 at 1:53 PM, Jerry D. Hedden <[EMAIL PROTECTED]> wrote:
> >  My sample worked OK *after* I removed the Data::Dumper
>  >  print; apparently, it has some issues w/ circular
>  >  references as well (I tried setting Deepcopy and
>  >  Purity, to no avail); I suspect its due to the fact
>  >  that references to shared elements don't have the same
>  >  stringified value, so it doesn't actually look like
>  >  a circular ref.
>
>  Oh, yes.  That's part of what I reported here:
>
>     http://rt.perl.org/rt3/Public/Bug/Display.html?id=37946
>
>  The following highlights the problem:
>
>
>     use strict;
>     use warnings;
>
>     use threads;
>     use threads::shared;
>
>     my $x;
>     $x = \$x;
>     share($x);
>
>     print("Look at \$x:\n");
>     print($x, "\n");
>     print($$x, "\n");
>     print($$$x, "\n");
>     print($$$$x, "\n");
>     print($$$$$x, "\n");
>     print($$$$$$x, "\n");
>
>     my @q :shared = ($x);
>
>     my $y = $q[0];
>
>     print("\nFirst look at \$y:\n");
>     print($y, "\n");
>     print($$y, "\n");
>     print($$$y, "\n");
>     print($$$$y, "\n");
>     print($$$$$y, "\n");
>     print($$$$$$y, "\n");
>
>     print("\nSecond look at \$y:\n");
>     print($y, "\n");
>     print($$y, "\n");
>     print($$$y, "\n");
>     print($$$$y, "\n");
>     print($$$$$y, "\n");
>     print($$$$$$y, "\n");
>
>  This outputs:
>
>     Look at $x:
>     REF(0x144f8f0)
>     REF(0x144f8f0)
>     REF(0x144f8f0)
>     REF(0x144f8f0)
>     REF(0x144f8f0)
>     REF(0x144f8f0)
>
>     First look at $y:
>     SCALAR(0x1423c70)
>     SCALAR(0x1423ad8)
>     SCALAR(0x14bd968)
>     SCALAR(0x14bd980)
>     SCALAR(0x14bd998)
>     SCALAR(0x14bd9b0)
>
>     Second look at $y:
>     REF(0x1423c70)
>     REF(0x1423ad8)
>     REF(0x14bd968)
>     REF(0x14bd980)
>     REF(0x14bd998)
>     SCALAR(0x14bd9b0)
>
>  Seems to me that this is a bug.  It shows that
>  threads::shared isn't detecting that it's dealing with a
>  circular reference.  With each level that the app traverses,
>  threads::shared "unrolls" another version of the shared
>  variable.

I just posted a patch to blead that fixes this.  If the patch passes
muster, I'll release an update for threads::shared to CPAN.

Reply via email to