Skip Menu |
 

This queue is for tickets about the List-MoreUtils CPAN distribution.

Report information
The Basics
Id: 20258
Status: resolved
Priority: 0/
Queue: List-MoreUtils

People
Owner: Nobody in particular
Requestors: steve [...] fisharerojo.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Core dump in each_array iterator
Download (untitled) / with headers
text/plain 1.4k
This ticket was opened by mistake as a Perlbug ticket. It appears it should have been opened here instead. It was ticket #39650: require and List::MoreUtils seg fault. Example code: #!/usr/bin/perl use strict; use warnings; require List::MoreUtils; # use List::MoreUtils (); my @v1 = qw(4 0 0 3); my @v2 = qw(4 0 0 3); my $ea = List::MoreUtils::each_array(@v1, @v2); while (my ($v, $t) = $ea->()) { } __END__ When running the above, I get a seg fault. Switch out the require to use, and the seg fault goes away. This has been confirmed on 5.8.7 on XP as well in this thread: http://www.perlmonks.org/index.pl?node_id=557894 Later in the ticket... A backtrace gives this : #0 0xb7eb6142 in Perl_av_fetch () from /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so #1 0xb7c531ec in XS_List__MoreUtils__array_iterator () from /usr/lib/perl5/vendor_perl/5.8.8/i386-linux/auto/List/MoreUtils/MoreUtils.so #2 0xb7ebd73d in Perl_pp_entersub () from /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so #3 0xb7eb6ae5 in Perl_runops_standard () from /usr/lib/perl5/5.8.8/i386- \ #linux/CORE/libperl.so #4 0xb7e63503 in perl_run () from /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so #5 0x080490d1 in main () So the problem probably comes from the implementation of List::MoreUtils::each_array (the _array_iterator function being instantiated as a closure at run-time) and is not related to core perl (although it's still a bit obscure for me)
Subject: Re: [rt.cpan.org #20258] Core dump in each_array iterator
Date: Tue, 4 Jul 2006 08:24:02 -0400
To: bug-List-MoreUtils [...] rt.cpan.org
From: Tassilo von Parseval <tassilo.von.parseval [...] rwth-aachen.de>
Download (untitled) / with headers
text/plain 2.7k
Hi there, Thank you for the report. Actually, I stumbled over this perlmonks threads a few days ago by chance... On Jul 3, 2006, at 8:37 AM, via RT wrote: Show quoted text
> > Mon Jul 03 08:37:33 2006: Request 20258 was acted upon. > Transaction: Ticket created by SMPETERS > Queue: List-MoreUtils > Subject: Core dump in each_array iterator > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: steve@fisharerojo.org > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=20258 > > > > This ticket was opened by mistake as a Perlbug ticket. It appears it > should have been opened here instead. It was ticket #39650: > require and > List::MoreUtils seg fault. > > Example code: > > #!/usr/bin/perl > use strict; > use warnings; > > require List::MoreUtils; > # use List::MoreUtils (); > > my @v1 = qw(4 0 0 3); > my @v2 = qw(4 0 0 3); > > my $ea = List::MoreUtils::each_array(@v1, @v2); > while (my ($v, $t) = $ea->()) > { > } > __END__ > > When running the above, I get a seg fault. Switch out the require to > use, and the seg fault goes away. This has been confirmed on 5.8.7 on > XP as well in this thread: http://www.perlmonks.org/index.pl? > node_id=557894 > > Later in the ticket... > > A backtrace gives this : > #0 0xb7eb6142 in Perl_av_fetch () from > /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so > #1 0xb7c531ec in XS_List__MoreUtils__array_iterator () > from > /usr/lib/perl5/vendor_perl/5.8.8/i386-linux/auto/List/MoreUtils/ > MoreUtils.so > #2 0xb7ebd73d in Perl_pp_entersub () from > /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so > #3 0xb7eb6ae5 in Perl_runops_standard () from /usr/lib/perl5/5.8.8/ > i386- > \ #linux/CORE/libperl.so > #4 0xb7e63503 in perl_run () from > /usr/lib/perl5/5.8.8/i386-linux/CORE/libperl.so > #5 0x080490d1 in main () > > So the problem probably comes from the implementation of > List::MoreUtils::each_array (the _array_iterator function being > instantiated as a closure at run-time) and is not related to core perl > (although it's still a bit obscure for me)
I would say this is a problem of compile- versus runtime initialization. In short: List::MoreUtils makes heavy use of prototypes. each_array has one, too and for it to work the module needs to be loaded at compile-time which is the case when doing 'use List::MoreUtils'. What happens in the require-case is that the prototype is ignored and each_array gets to see now references to arrays but a plain list. There is no fix for that other than adding a warning to the documentation maybe, I am afraid. For the given case, consider using each_arrayref which will work with require as it does not involve any prototypes: my $ea = List::MoreUtils::each_arrayref(\@v1, \@v2); while (my ($v, $t) = $ea->()) { print "$v -- $t\n"; } Cheers, Tassilo
Download (untitled) / with headers
text/plain 353b
I notice this happens from each_arrayref too, without "use" vs "require" getting in the way. use List::MoreUtils; my $ea = List::MoreUtils::each_arrayref ('foo'); print $ea->(); => segfault I wonder if the code (common to the two funcs) could check SvROK (or whatever the right test is :-) on its args, as a protection against passing something bad.
This is resolved in 0.23 which I just uploaded to the CPAN.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.