New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List::Util::uniqnum() broken in current Scalar-List-Utils #17174
Comments
From @sisyphusThe dual-life module Scalar-List-Utils is currently at version 1.52. The pull request at Dual-Life/Scalar-List-Utils#79 All perl configurations are subject to uniqnum() failures, though not all How should I proceed to have this fixed in time for perl-5.32 ? Cheers, Summary of my perl5 (revision 5 version 31 subversion 4) configuration: Platform: Characteristics of this binary (from libperl): |
From @sisyphus#!./perl use strict; use Tie::Array; is_deeply( [ uniqstr ], is_deeply( [ uniqstr qw( abc ) ], is_deeply( [ uniqstr qw( x x x ) ], is_deeply( [ uniqstr qw( a b a c ) ], is_deeply( [ uniqstr qw( 1 1.0 1E0 ) ], { is_deeply( [ uniqstr "", undef ], ok( length $warnings, 'uniqstr on undef yields a warning' ); is_deeply( [ uniqstr undef ], SKIP: { my $cafe = "cafe\x{301}"; is_deeply( [ uniqstr $cafe ], SKIP: { is_deeply( [ uniqstr $cafe, $cafebytes ], is( $warnings, "", 'No warnings are printed when handling Unicode strings' ); if($Config{nvsize} == 8 && $Config{ivsize} == 8) { is_deeply( [ uniqnum qw( 1 1.0 1E0 2 3 9223372036854775808 9.2233720368547758e+18) ], else { is_deeply( [ uniqnum qw( 1 1.0 1E0 2 3 ) ], is_deeply( [ uniqnum qw( 1 1.1 1.2 1.3 ) ], { my @strings = map "$_", @nums; my ($uniq_count1, $uniq_count2, $equiv); if($Config{nvsize} == 8) { # The 2 values should be unequal - but just in case perl is buggy: $uniq_count1 = List::Util::uniqnum (1.4142135623730951, $uniq_count2 = List::Util::uniqnum('1.4142135623730951', elsif(length(sqrt(2)) > 25) { if(1 + (2 ** -1074) != 1) { # The 2 values should be unequal - but just in case perl is buggy: $uniq_count1 = List::Util::uniqnum (1 + (2 ** -1074), $uniq_count2 = List::Util::uniqnum('4.0564819207303340847894502572035e31', else { # The 2 values should be unequal - but just in case perl is buggy: $uniq_count1 = List::Util::uniqnum (1.7320508075688772935274463415058722, $uniq_count2 = List::Util::uniqnum('1.7320508075688772935274463415058722', else { # The 2 values should be unequal - but just in case perl is buggy: $uniq_count1 = List::Util::uniqnum (2.2360679774997896963, $uniq_count2 = List::Util::uniqnum('2.2360679774997896963', if($equiv) { else { SKIP: { my @in = (~0, ~0 - 1, 18446744073709551614.0, 18014398509481985, 1.8014398509481985e16); # On perl-5.6.2 (and perhaps other old versions), ~0 - 1 is assigned to an NV. if("$in[1]" eq "1.84467440737096e+19") { # It's an NV and $in[2] is a duplicate of $in[1] # No duplicates in @in is_deeply( [ uniqnum @in ], # Hard to know for sure what an Inf is going to be. Lets make one is_deeply( [ uniqnum 0, 1, 12345, $Inf, -$Inf, $NaN, 0, $Inf, $NaN ], SKIP: { my @nums = ($maxuint, $maxuint-1, -1, $Inf, $NaN, $maxint, $minint, 1 ); is_deeply( [ uniqnum @nums, 1.0 ], my @strs = map "$_", @nums; if($maxuint !~ /\A[0-9]+\z/) { is_deeply( [ uniqnum @strs, "1.0" ], { is_deeply( [ uniqnum 0, undef ], ok( length $warnings, 'uniqnum on undef yields a warning' ); is_deeply( [ uniqnum undef ], is_deeply( [uniqnum 0, -0.0 ], is_deeply( [ uniq () ], { is_deeply( [ uniq "", undef ], is_deeply( [ uniq undef, undef ], ok( !length $warnings, 'uniq on undef does not warn' ); is( scalar( uniqstr qw( a b c d a b e ) ), 5, 'uniqstr() in scalar context' ); { use overload '""' => sub { return $_[0]->{str} }; sub new { bless { str => $_[1] }, $_[0] } package main; my @strs = map { Stringify->new( $_ ) } qw( foo foo bar ); is_deeply( [ map "$_", uniqstr @strs ], { use overload '0+' => sub { return $_[0]->{num} }; sub new { bless { num => $_[1] }, $_[0] } package main; my @nums = map { Numify->new( $_ ) } qw( 2 2 5 ); # is_deeply wants to use eq overloading { use overload '""' => sub { "SAME" }; sub new { bless { var => $_[1] }, $_[0] } sub DESTROY { ${ $_[0]->{var} }++ } package main; my @destroyed = (0) x 3; my @uniqstr = uniqstr @notifiers; is_deeply( \@destroyed, [ 0, 1, 1 ], undef @uniqstr; { "1 1 2" =~ m/(.) (.) (.)/; { my @u = uniq @array; |
From @jkeenanOn Sat, 05 Oct 2019 04:23:25 GMT, sisyphus359@gmail.com wrote:
It's unclear from this ticket what the failures in List::Util::uniqnum() actually are. Perhaps more to the point, the ticket doesn't make clear *where* they occur. Is this a Windows-specific problem? Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @sisyphusOn Sat, 05 Oct 2019 05:03:46 -0700, jkeenan wrote:
It's something that afflicts all systems, and all configurations of perl. Here's one example of a failure that will appear on all configurations of blead: $ perl -MList::Util="uniqnum" -le '@x = uniqnum(1.4142135623730951, 1.4142135623730954); print "@x";' Here uniqnum() is asserting that 1.4142135623730951 and 1.4142135623730954 are the same value, even though perl itself recognizes that the 2 values are distinct: $ perl -le 'print "ok" if 1.4142135623730951 != 1.4142135623730954;' Another failure across all configurations is: perl -MList::Util="uniqnum" -le '@x = uniqnum(0, -0.0); print "@x";' In this instance, uniqnum() is asserting that 0 and -0.0 are different values. And here's a third example that afflicts only those perl configurations where both $Config{ivsize} and $Config{nvsize} are 8: $ perl -MList::Util="uniqnum" -le '@x = uniqnum(9223372036854775808, 9.2233720368547758e+18); print "@x";' Here, uniqnum() asserts that 9223372036854775808 and 9.2233720368547758e+18 are different values even though they are both exact representations of 2 ** 63. These examples are drawn from the extended version of uniq.t that I attached to my initial bug report. Cheers, |
From @leonerdOn Fri, 04 Oct 2019 21:23:25 -0700
I've been waiting until you get to the end of adjusting that PR before Is it now ready to merge? -- leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS |
From @sisyphusOn Sat, 05 Oct 2019 07:33:27 -0700, leonerd@leonerd.org.uk wrote:
Yes, it's now ready. Cheers, |
Since my last post to this thread, we've moved on to Please take a look, and then we can work out how to proceed. As it stands in perl-5.31.5 and earlier, I think uniqnum() is currently fit for purpose so long as all numbers are either IVs or UVs. For tonight's weird example: Cheers, |
On 10/22/19 2:42 PM, sisyphus wrote:
Since my last post to this thread, we've moved on to
Dual-Life/Scalar-List-Utils#80
<Dual-Life/Scalar-List-Utils#80>
which is now, IMO, ready for merging.
Please take a look, and then we can work out how to proceed.
As it stands in perl-5.31.5 and earlier, I think uniqnum() is currently
fit for purpose so long as all numbers are either IVs or UVs.
But it is is not fit for purpose when NVs (either integral or fractional
values) that cannot be accurately represented in 15 or fewer decimal
digits are involved.
For tonight's weird example:
$c = uniqnum(2 ** 50, 1 * (2 ** 50));
will set $c to 2 (unless $Config{ivsize} == 4, which is rare these days).
$c should, of course, be set to 1, as both values are identical.
The error arises partly because the first argument is an NV while the
second is an IV, and partly because 2 ** 50 requires more than 15
decimal digits of precision for accurate representation.
Similarly for exponents in the range 51..63, and for a vast number of
other integral values.
Cheers,
Rob
Rob, thank you for your continuing investigations into this.
In terms of the Perl 5 core distribution, Scalar-List-Utils is "cpan
unstream" at the present time. That means that if you've got code in
the Dual Life repository it first needs to be merged into the codebase
maintained currently by Paul Evans and he needs to issue a new CPAN
version. One of us (perhaps me) will then merge it into Perl 5 blead.
Paul attended the Perl 5 Core Summit in Amsterdam this past weekend and
we did have some discussion as to whether Scalar-List-Utils should
become "p5p upstream" with respect to its maintenance -- in which case
it would move to the "dist/" hierarchy within the core distribution. No
decision was made on that. Hence, for the meantime you should
communicate with the upstream maintainer(s).
Thank you very much.
Jim Keenan
|
@leonerd FYI |
Sorry to raise it again here, but nothing has been done about this.
That's ok ... it doesn't have to be fixed immediately. I'm happy so long as
it's fixed in 5.32.0.
To that end, I'd like to know what I need to do to ensure that it's made a
5.32.0 blocker.
Presumably a request for blocker status might be rejected on the basis of
"insufficient notice" if one waits too long in the cycle before lodging
that request.
(And I guess the same request might be forgotten and lost if made too early
in the cycle.)
Cheers,
Rob
On Wed, Oct 23, 2019 at 3:57 AM James E Keenan <notifications@github.com>
wrote:
…
On 10/22/19 2:42 PM, sisyphus wrote:
> Since my last post to this thread, we've moved on to
> Dual-Life/Scalar-List-Utils#80
> <Dual-Life/Scalar-List-Utils#80>
> which is now, IMO, ready for merging.
>
> Please take a look, and then we can work out how to proceed.
>
> As it stands in perl-5.31.5 and earlier, I think uniqnum() is currently
> fit for purpose so long as all numbers are either IVs or UVs.
> But it is is not fit for purpose when NVs (either integral or fractional
> values) that cannot be accurately represented in 15 or fewer decimal
> digits are involved.
>
> For tonight's weird example:
> $c = uniqnum(2 ** 50, 1 * (2 ** 50));
> will set $c to 2 (unless $Config{ivsize} == 4, which is rare these days).
> $c should, of course, be set to 1, as both values are identical.
> The error arises partly because the first argument is an NV while the
> second is an IV, and partly because 2 ** 50 requires more than 15
> decimal digits of precision for accurate representation.
> Similarly for exponents in the range 51..63, and for a vast number of
> other integral values.
>
> Cheers,
> Rob
>
Rob, thank you for your continuing investigations into this.
In terms of the Perl 5 core distribution, Scalar-List-Utils is "cpan
unstream" at the present time. That means that if you've got code in
the Dual Life repository it first needs to be merged into the codebase
maintained currently by Paul Evans and he needs to issue a new CPAN
version. One of us (perhaps me) will then merge it into Perl 5 blead.
Paul attended the Perl 5 Core Summit in Amsterdam this past weekend and
we did have some discussion as to whether Scalar-List-Utils should
become "p5p upstream" with respect to its maintenance -- in which case
it would move to the "dist/" hierarchy within the core distribution. No
decision was made on that. Hence, for the meantime you should
communicate with the upstream maintainer(s).
Thank you very much.
Jim Keenan
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17174?email_source=notifications&email_token=AAAR3PHSINTCLBSNPAXAQT3QP4WHJA5CNFSM4JDPD3IKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB6ORKY#issuecomment-545056939>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAR3PH4JIBREWBZNAY7SSDQP4WHJANCNFSM4JDPD3IA>
.
|
@leonerd, Can you take a look at this? Thank you very much. |
How does this relate to the Scalar-List-Utils issue Dual-Life/Scalar-List-Utils#84 ? |
I wanted to check on how the latest PR (
Dual-Life/Scalar-List-Utils#84 ) would fare with
cpan testers.
So I created List::Uniqnum, which uses the uniqnum() implementation
presented in that PR.
It has been testing fine - but annoyingly, in creating Uniqnum.xs, I
introduced some scoping issues that prevented the XS code from compiling
with at least some MS compilers.
So I've just uploaded List-Uniqnum-0.02 (which fixes that scoping issue) to
CPAN.
BTW, I don't think that scoping issue existed with the code in the PR.
But the difference is due to layout. The uniqnum() implementation in
List-Uniqnum-0.02 is essentially the same as the implementation in that PR.
I expect List-Uniqnum-0.02 to fail test 8 with some (if not all) MS
compilers - though I don't think there any smokers using MS compilers.
I have a perl-5.16.0 built with a Microsoft Platform SDK toolchain -
"Program Maintenance Utility Version 7.00.8882", "C/C++ Optimizing
Compiler Version 14.00.40310.41".
It fails test 8.
But I don't have a current MS compiler to see whether that issue still
exists.
The issue with my L-U-0.02's test 8 and MS compilers should be fixed in the
next day or two, and released to CPAN as List-Uniqnum-0.03.
When 0.03 is released, I'll send out a few messages (eg ping Steve Hay,
post to perlmonks) requesting some testing of it on perls that use an MS
compiler - and any other systems that have the propensity to be troublesome.
At that time, I'll post an update message to
Dual-Life/Scalar-List-Utils#84
Of course, anyone who wants to "cpan -i List::Uniqnum" at any time, is most
welcome to do so.
Please report any issues - either publicly or to me, privately.
The main purpose of getting List::Uniqnum out there is to find out if there
are any issues with that PR that I don't know about.
Cheers,
Rob
…On Wed, Jan 29, 2020 at 9:13 AM James E Keenan ***@***.***> wrote:
@leonerd <https://github.com/leonerd>, Can you take a look at this?
Thank you very much.
Jim Keenan
@leonerd <https://github.com/leonerd>, can you take a look at this
problem with List::Util::uniqnum?
Thank you very much.
Jim Keenan
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17174?email_source=notifications&email_token=AAAR3PC5POJL6A45GQJEERDRACUZBA5CNFSM4JDPD3IKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKFDXZY#issuecomment-579484647>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAR3PEEVS3UIIZCWW532A3RACUZBANCNFSM4JDPD3IA>
.
|
I don't understand where we're standing on this. @leonerd can you provide your view of it? |
@xsawyerx, I realize that your question was not directed to me, but I have information that I feel may be relevant to your question. The PR at Dual-Life/Scalar-List-Utils#99 has since been approved, and we're now up to considering my latest PR, which is: The code proposed in Dual-Life/Scalar-List-Utils#100 has been testing fine in List-Uniqnum-0.11. There's a couple of UNKNOWN results due, pretty clearly, to something other than the code - ie a problem with the configuration of the particular smoker, and/or some quirk of the way that the List::Uniqnum source distro has been assembled. With the committing of Dual-Life/Scalar-List-Utils#99, most of the issues that I know of regarding List::Util::uniqnum were taken care of. Dual-Life/Scalar-List-Utils#100 addresses all issues that I know of - including an additional issue with DoubleDouble builds that I was unaware of when I proposed Dual-Life/Scalar-List-Utils#99. IMO, Dual-Life/Scalar-List-Utils#100 is bug free - though there may be one or more perl bugs, on some system, for some version of perl, that brings it undone. I recognize that there's no guarantee that the test suite is not failing to detect some issue. Oh ... one more thing ... there may be a more efficient fix for that DoubleDouble problem that I mentioned above. I've made some bold and confident assertions in this post. Cheers, |
@sisyphus I appreciate the thorough rundown and the valuable, tireless work you've done on this. I would like to see these changes merged into Scalar-List-Util and have it merged within a development release. @leonerd can you give an update on Dual-Life/Scalar-List-Utils#100? |
For anyone following along, Scalar-List-Utils 1.55 includes the fix for this. |
Thanks, @tonycoz. :) |
I should point out that, although these particular issues with uniqnum have been fixed in 1.55 the uniqint function, which was introduced out-of-the-blue in 1.55, is broken. See Dual-Life/Scalar-List-Utils#105 which, I believe, fixes those remaining uniqint issues. Cheers, |
Migrated from rt.perl.org#134481 (status was 'open')
Searchable as RT134481$
The text was updated successfully, but these errors were encountered: