Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ansgar [...] 2008.43-1.org
Cc:
AdminCc:

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



Subject: minmax() one arg access below stack
Date: Sun, 19 Jul 2009 23:10:29 +0200
To: bug-List-MoreUtils [...] rt.cpan.org
From: Ansgar Burchardt <ansgar [...] 2008.43-1.org>
Hi, I'm forwarding this bug report from the Debian BTS [1]. Regards, Ansgar [1] http://bugs.debian.org/532534
Subject: liblist-moreutils-perl: minmax() one arg access below stack
Date: Wed, 10 Jun 2009 07:26:25 +1000
To: submit [...] bugs.debian.org
From: Kevin Ryde <user42 [...] zip.com.au>
Package: liblist-moreutils-perl Version: 0.22-1+b1 Severity: normal Tags: patch The program foo.pl below gets errors Use of uninitialized value in subroutine entry at foo.pl line 5. Use of uninitialized value $min in concatenation (.) or string at foo.pl line 6. where I hoped minmax() would return 100 for both minimum and maximum when called with one arg. I think the xsub for minmax() when with just one arg, ie. items==1, accesses an item below its args on the stack. In the code if (items & 1) { asv = ST(items-2); the ST(items-2) is ST(-1). No doubt what's there depends on the calling context or something. foo.pl seems to see an undef, in one of my programs I struck "non-numeric" warnings for hitting an alphabetic string. Perhaps items==1 can shortcut to the end of the func like below. The ref counting is right just duplicating an existing arg, is it? I think EXTEND(SP,2) is certainly needed though, the code shouldn't store ST(1) at the end unless either items>=2 or an EXTEND. Incidentally, the corresponding code in the pure-perl implementation is ok because of course there $_[-1] on a length-one @_ means $_[0]. -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i586) Kernel: Linux 2.6.26-1-486 Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/dash Versions of packages liblist-moreutils-perl depends on: ii libc6 2.9-13 GNU C Library: Shared libraries ii perl 5.10.0-22 Larry Wall's Practical Extraction ii perl-base [perlapi-5.10.0] 5.10.0-22 minimal Perl system liblist-moreutils-perl recommends no packages. liblist-moreutils-perl suggests no packages. -- no debconf information
use strict; use warnings; use List::MoreUtils 'minmax'; my ($min, $max) = minmax(100); print "$min $max\n";
--- MoreUtils.xs.orig 2009-06-08 15:25:26.000000000 +1000 +++ MoreUtils.xs 2009-06-08 15:25:49.000000000 +1000 @@ -1202,6 +1202,10 @@ XSRETURN_EMPTY; minsv = maxsv = ST(0); + if (items == 1) { + EXTEND (SP, 2); + goto done; + } min = max = slu_sv_value(minsv); for (i = 1; i < items; i += 2) { @@ -1255,6 +1259,7 @@ } } } + done: ST(0) = minsv; ST(1) = maxsv;
This will be fixed in 0.24 which will be out in a couple of days.
I believe this is now fixed again