[EMAIL PROTECTED] (via RT) wrote:
> The folllowing test program crashes perl:
> 
> -------------------
> use threads;
> use threads::shared;
> my @list : shared;
> push(@list, &share(new A));
> foreach $a (@list) {
>     $a->{n};         # <-- needed to produce segmentation fault

$a is aliased to the element of @list; @list being shared, its
elements need to be too, but perl doesn't check this.

>     print "$a\n";    # <-- segmentation fault
> }
> 
> package A;
> sub new {
>     return bless {};
> }

With a debugging threaded bleadperl, your program gives this output :

__ANON__=HASH(0x8246e44)
Assertion my_perl == PL_sharedsv_space failed: file "shared.xs", line 181.

showing where the crash occurs (with non-debugging perls).

But using &share to bypass prototype checking is evil, as share is
intended to be used on variables only.

> Additional observations:
> 
> 1) Replacing the foreach loop with a for loop seems to work
>    around the bug:

Because aliasing is no longer involved.

> 2) Removing the bless eliminates the crash but generates some
>    scalar leaked warnings.

Reply via email to