Skip Menu |
 

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 113310
Status: resolved
Priority: 0/
Queue: Math-BigInt

People
Owner: Nobody in particular
Requestors: craigberry [...] mac.com
Cc:
AdminCc:

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



MIME-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Spam-Status: No, score=-4.749 tagged_above=-99.9 required=10 tests=[AWL=-2.150, BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
X-Mailer: Apple Mail (2.3124)
X-Spam-Flag: NO
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1603240261
Message-ID: <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com>
content-type: text/plain; charset="utf-8"
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -4.749
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id C6042240377 for <cpan-bug+Math-Bigint [...] hipster.bestpractical.com>; Thu, 24 Mar 2016 13:00:59 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Oj0xbA+aJ+d2 for <cpan-bug+Math-Bigint [...] hipster.bestpractical.com>; Thu, 24 Mar 2016 13:00:53 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BBED62402FF for <bug-Math-Bigint [...] rt.cpan.org>; Thu, 24 Mar 2016 13:00:52 -0400 (EDT)
Received: (qmail 21944 invoked by alias); 24 Mar 2016 17:00:52 -0000
Received: from pv33p03im-asmtp001.me.com (HELO pv33p03im-asmtp001.me.com) (17.143.180.10) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 24 Mar 2016 10:00:49 -0700
Received: from [172.16.52.2] (c-24-14-137-179.hsd1.il.comcast.net [24.14.137.179]) by pv33p03im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) with ESMTPSA id <0O4J00DNMZ8YBG40 [...] pv33p03im-asmtp001.me.com> for bug-Math-Bigint [...] rt.cpan.org; Thu, 24 Mar 2016 17:00:45 +0000 (GMT)
Delivered-To: cpan-bug+Math-Bigint [...] hipster.bestpractical.com
Subject: OpenSSL test suite fails with Math::Bigint 1.999701
Return-Path: <craigberry [...] mac.com>
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-03-24_07:,, signatures=0
X-RT-Mail-Extension: math-bigint
X-Original-To: cpan-bug+Math-Bigint [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Date: Thu, 24 Mar 2016 12:00:34 -0500
X-Spam-Level:
To: bug-Math-Bigint [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Craig A. Berry" <craigberry [...] mac.com>
X-RT-Original-Encoding: utf-8
X-RT-Interface: Email
Content-Length: 2436
Download (untitled) / with headers
text/plain 2.3k
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
MIME-Version: 1.0
In-Reply-To: <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-27830-1458908707-753.113310-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1009
Download (untitled) / with headers
text/plain 1009b
This was a bug that has now been fixed. It was one of countless cases where the code and documentation didn't match. The code did truncated division whereas the documentation said that floored division was used. I decided to change the code to match the documentation, rather than the other way around, to be consistent with core Perl, and so that division (/) and modulo (%) can be used together in a consistent way. With the new behaviour, the following is true for all finite x and finite and non-zero y: x = y * (x / y) + (x % y) The above was not always true with the old behaviour. Consider the simple case -5 / 4. -5 % 4 = 3 # core Perl and bmod() -5 / 4 = -1 # old behaviour of bdiv() -5 / 4 = -2 # new behaviour of bdiv() The only way the following can be true is if -5 / 4 = -2 -5 = 4 * (-5 / 4) + 3 For what it's worth, the new behaviour matches how integer division is done in Python $ python -c 'print(-5 / 4)' -2 $ python3 -c 'print(-5 // 4)' -2
MIME-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Spam-Status: No, score=-6.534 tagged_above=-99.9 required=10 tests=[AWL=0.065, BAYES_00=-1.9, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-27830-1458908708-350.113310-6-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.3124)
X-Spam-Flag: NO
X-RT-Interface: API
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1603250238
References: <RT-Ticket-113310 [...] rt.cpan.org> <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com> <rt-4.0.18-27830-1458908708-350.113310-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
content-type: text/plain; charset="utf-8"
Message-ID: <82A73808-98F4-4C66-A410-BFDF68F0D791 [...] mac.com>
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.534
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 679E92403BC for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 25 Mar 2016 11:28:30 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PwSyr76Drujz for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 25 Mar 2016 11:28:29 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BC11D24037A for <bug-Math-BigInt [...] rt.cpan.org>; Fri, 25 Mar 2016 11:28:28 -0400 (EDT)
Received: (qmail 7689 invoked by alias); 25 Mar 2016 15:28:28 -0000
Received: from pv33p03im-asmtp002.me.com (HELO pv33p03im-asmtp002.me.com) (17.143.180.11) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 25 Mar 2016 08:28:24 -0700
Received: from [172.16.52.2] (c-24-14-137-179.hsd1.il.comcast.net [24.14.137.179]) by pv33p03im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) with ESMTPSA id <0O4L00K4EPMY3D00 [...] pv33p03im-asmtp002.me.com> for bug-Math-BigInt [...] rt.cpan.org; Fri, 25 Mar 2016 15:28:11 +0000 (GMT)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #113310] OpenSSL test suite fails with Math::Bigint 1.999701
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-03-25_03:,, signatures=0
Return-Path: <craigberry [...] mac.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Fri, 25 Mar 2016 10:28:09 -0500
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Craig A. Berry" <craigberry [...] mac.com>
RT-Message-ID: <rt-4.0.18-5999-1458919711-1131.113310-0-0 [...] rt.cpan.org>
Content-Length: 1161
Download (untitled) / with headers
text/plain 1.1k
OK, thanks. So if the new behavior is a correction, then presumably OpenSSL’s big number library needs the same correction or something needs clarification about whether it’s intentionally doing truncated division (the test that fails is a right shift test, so that may be the case). As far as I can tell, what they are doing is performing a series of calculations, printing out the result of each step, reversing the calculations with the expectation of a zero result, then reading in what’s been printed out and reproducing the reverse calculation using Math::BigInt. This based on a quick read of: <http://git.openssl.org/?p=openssl.git;a=blob;f=test/bntest.c;h=e58d94d1170e787ce94eb4b52a1759fef364c9f7;hb=HEAD#l1962> and <http://git.openssl.org/?p=openssl.git;a=blob;f=test/recipes/10-test_bn.t;h=7e728f4e16847b4eb487ab937dadbb0b2880d68c;hb=HEAD> I guess I will pass this along to openssl-dev and point to this ticket. OpenSSL 1.1.0 and Perl 5.24.0 are likely to be released around the same time in the next couple of months. Obviously it’s in no one’s interest to have random test failures that result from this particular combination.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-5999-1458919711-1131.113310-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-113310 [...] rt.cpan.org> <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com> <rt-4.0.18-27830-1458908708-350.113310-6-0 [...] rt.cpan.org> <82A73808-98F4-4C66-A410-BFDF68F0D791 [...] mac.com> <rt-4.0.18-5999-1458919711-1131.113310-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-5999-1458924802-651.113310-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 558
Download (untitled) / with headers
text/plain 558b
On Fri Mar 25 11:28:31 2016, craigberry@mac.com wrote: Show quoted text
> I guess I will pass this along to openssl-dev and point to this > ticket. OpenSSL 1.1.0 and Perl 5.24.0 are likely to be released around > the same time in the next couple of months. Obviously it’s in no one’s > interest to have random test failures that result from this particular > combination.
I would very much appreciate it if you did pass this along to openssl-dev. I thought about implementing a btdiv() method that did truncated division, but I have given other changes higher priority.
MIME-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Spam-Status: No, score=-6.54 tagged_above=-99.9 required=10 tests=[AWL=0.059, BAYES_00=-1.9, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-5999-1458924802-197.113310-6-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.3124)
X-Spam-Flag: NO
X-RT-Interface: API
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1603250315
References: <RT-Ticket-113310 [...] rt.cpan.org> <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com> <rt-4.0.18-27830-1458908708-350.113310-6-0 [...] rt.cpan.org> <82A73808-98F4-4C66-A410-BFDF68F0D791 [...] mac.com> <rt-4.0.18-5999-1458919711-1131.113310-6-0 [...] rt.cpan.org> <rt-4.0.18-5999-1458924802-197.113310-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
content-type: text/plain; charset="utf-8"
Message-ID: <B7C2EC6B-B04D-4D55-A047-142DA433C04B [...] mac.com>
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.54
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B33FB2403C6 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 25 Mar 2016 17:01:55 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aFV488yUlaSd for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 25 Mar 2016 17:01:53 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 46C4E24037A for <bug-Math-BigInt [...] rt.cpan.org>; Fri, 25 Mar 2016 17:01:52 -0400 (EDT)
Received: (qmail 30228 invoked by alias); 25 Mar 2016 21:01:51 -0000
Received: from pv33p03im-asmtp001.me.com (HELO pv33p03im-asmtp001.me.com) (17.143.180.10) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 25 Mar 2016 14:01:45 -0700
Received: from [172.16.52.2] (c-24-14-137-179.hsd1.il.comcast.net [24.14.137.179]) by pv33p03im-asmtp001.me.com (Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015)) with ESMTPSA id <0O4M0063O52NUQ00 [...] pv33p03im-asmtp001.me.com> for bug-Math-BigInt [...] rt.cpan.org; Fri, 25 Mar 2016 21:01:41 +0000 (GMT)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #113310] OpenSSL test suite fails with Math::Bigint 1.999701
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-03-25_06:,, signatures=0
Return-Path: <craigberry [...] mac.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Fri, 25 Mar 2016 16:01:35 -0500
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Craig A. Berry" <craigberry [...] mac.com>
RT-Message-ID: <rt-4.0.18-32040-1458939716-136.113310-0-0 [...] rt.cpan.org>
Content-Length: 598
Download (untitled) / with headers
text/plain 598b
Show quoted text
> On Mar 25, 2016, at 11:53 AM, Peter John Acklam via RT <bug-Math-BigInt@rt.cpan.org> wrote: > > I would very much appreciate it if you did pass this along to openssl-dev.
There is a ticket open there now: <http://rt.openssl.org/Ticket/Display.html?id=4485&user=guest&pass=guest> which shows up on the openssl-dev mailing list at: <https://mta.openssl.org/pipermail/openssl-dev/2016-March/006451.html> Show quoted text
________________________________________ Craig A. Berry mailto:craigberry@mac.com "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser
MIME-Version: 1.0
In-Reply-To: <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <65A327DF-BF82-4427-99D8-5273D2CDC947 [...] mac.com>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-8984-1460828700-704.113310-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 55
This has been fixed by changing the OpenSSL test suite.


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.