Subject: | OpenSSL test suite fails with Math::Bigint 1.999701 |
Date: | Thu, 24 Mar 2016 12:00:34 -0500 |
To: | bug-Math-Bigint [...] rt.cpan.org |
From: | "Craig A. Berry" <craigberry [...] mac.com> |
The following program gives a different answer with Math::Bigint 1.999701 than it did with previous releases. The data and the operations on it are taken from the OpenSSL test suite, which succeeds when run with Perl 5.22.1, but (sometimes) fails when run with 5.23.x (any version since Math::Bigint 1.999701 was integrated into blead).
It only fails sometimes because the data are generated using an RNG, and you don’t always get a data set that trips over this particular difference. When it does fail, there are dozens of failures, of which this is only one — let me know if more examples are of any use.
I have not looked at the math here, just narrowed it down to the fact that something that used to give a result of 0x0 now gives a result of -0x1.
$ cat testcase.pl
use strict;
use warnings;
use Math::BigInt;
my $operand1 = Math::BigInt->from_hex('-F7C3C3DADA0000FFA028FFFFFFFF4CFF737300000000003E3E');
my $operand2 = Math::BigInt->from_hex('4');
$operand1->bdiv($operand2);
my $operand3 = Math::BigInt->from_hex('-3DF0F0F6B680003FE80A3FFFFFFFD33FDCDCC0000000000F8F');
$operand1->bsub($operand3);
print $operand1->as_hex() . "\n";
exit ($operand1->as_hex() eq '0x0' ? 0 : 1);
[end]
I found this by using the above program to bisect blead and landing on:
b4a10d33925c921a1cacc15a612f2afe75eb4492 is the first bad commit
commit b4a10d33925c921a1cacc15a612f2afe75eb4492
Author: Peter John Acklam <pjacklam@online.no>
Date: Tue Apr 14 15:20:14 2015 +0200
Correct bdiv() and bmod() in Math::BigInt and Math::BigFloat
- The POD documentation, as well as the comments in the code, say that
$x->bdiv($y) in list context should return quotient $q and remainder $r
so that $x = $q * $y + $r, and that the remainder (modulo) $r should
correspond to Perl's % operator as well as the bmod() method. This has
not been the actual behaviour. This patch fixes this.
- Clearer POD documentation for the bdiv() and bmod() methods.
- Changed test files to match corrected behaviour.
- Removed some duplicated tests.
which upgraded blead to 1.999701 from 1.9997. The commit message talks only about changing behavior in list context, which I don’t see any of in the example I’ve provided.
Show quoted text
________________________________________
Craig A. Berry
mailto:craigberry@mac.com
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser