Skip Menu |

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

Report information
The Basics
Id: 114449
Status: open
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

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



Subject: segfault in List::Util::uniq when combined with sort
`sort uniq @list` has issues... test script: use strict; use warnings; use List::Util 'uniq'; my @list = qw(1 2 a b 4 9 c a 2 4 1); print "1 the sorted uniqed list is ", join(', ', sort(uniq(@list))), "\n"; print "2 the sorted uniqed list is ", join(', ', sort uniq @list), "\n"; on one machine (perl 5.14.2 x86_64-linux-gnu-thread-multi ubuntu), this produces: 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c Segmentation fault on another machine (perl 5.25.0, darwin-2level OSX 10.10.5) it produces: 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c Argument "b" isn't numeric in sort at list.pl line 7. Argument "a" isn't numeric in sort at list.pl line 7. Argument "a" isn't numeric in sort at list.pl line 7. Argument "c" isn't numeric in sort at list.pl line 7. 2 the sorted uniqed list is 1, 4, 2, 9, 4, 2, 1, a, b, c, a perl 5.14.4, darwin-2level OSX 10.10.5: 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c Segmentation fault: 11 perl 5.16.3, darwin-2level OSX 10.10.5 (and also 5.18.4, 5.20.3, 5.22.0, 5.22.2): 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c Sort subroutine didn't return single value at list.pl line 7.
On Tue May 17 18:32:07 2016, ETHER wrote: Show quoted text
> `sort uniq @list` has issues...
Are you trying to use uniq as the sort comparison routine? If not, put a + in front of it. The 5.25.0 output below is correct. Earlier perl versions had trouble with comparison routines that did not return just a single number. Show quoted text
> > test script: > > use strict; > use warnings; > > use List::Util 'uniq'; > my @list = qw(1 2 a b 4 9 c a 2 4 1); > print "1 the sorted uniqed list is ", join(', ', sort(uniq(@list))), > "\n"; > print "2 the sorted uniqed list is ", join(', ', sort uniq @list), > "\n"; > > > on one machine (perl 5.14.2 x86_64-linux-gnu-thread-multi ubuntu), > this produces: > > 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c > Segmentation fault > > > on another machine (perl 5.25.0, darwin-2level OSX 10.10.5) it > produces: > > 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c > Argument "b" isn't numeric in sort at list.pl line 7. > Argument "a" isn't numeric in sort at list.pl line 7. > Argument "a" isn't numeric in sort at list.pl line 7. > Argument "c" isn't numeric in sort at list.pl line 7. > 2 the sorted uniqed list is 1, 4, 2, 9, 4, 2, 1, a, b, c, a > > > perl 5.14.4, darwin-2level OSX 10.10.5: > > 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c > Segmentation fault: 11 > > > perl 5.16.3, darwin-2level OSX 10.10.5 (and also 5.18.4, 5.20.3, > 5.22.0, 5.22.2): > > 1 the sorted uniqed list is 1, 2, 4, 9, a, b, c > Sort subroutine didn't return single value at list.pl line 7.
On 2016-05-17 20:35:36, SPROUT wrote: Show quoted text
> On Tue May 17 18:32:07 2016, ETHER wrote:
> > `sort uniq @list` has issues...
> > Are you trying to use uniq as the sort comparison routine? If not, > put a + in front of it. > > The 5.25.0 output below is correct. Earlier perl versions had trouble > with comparison routines that did not return just a single number.
I should note that this is different behaviour from List::MoreUtils::uniq -- which is how I encountered this issue, when upgrading List::Util and List::AllUtils in my employer's system.