Skip Menu |

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

Report information
The Basics
Id: 124989
Status: open
Priority: 0/
Queue: Math-BigInt

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

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



Subject: BigInt wraps largest signed integer
Doing an operation that results in something beyond the largest signed integer results in undefined behavior in C. perl currently sets an option to gcc and other compilers to treat this as described in the man page -fwrapv This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This is a temporary kludge, because it is likely obscuring an underlying bug. I compiled 5.27.10 so that wrapv is not in effect (You can do this by passing this to Configure -Accflags='-ftrapv' -Accflags='-fno-wrapv' and found that all the Math-Bigfoo modules failed, for example ../cpan/Math-BigInt-FastCalc/t/bigintfc.t .......................... Failed 359/359 subtests The 5.29 series is likely to to remove this kludge, and the Bigfoo functions will start failing then. But, again this is likely hiding an existing bug. The core perl bug is https://rt.perl.org/Ticket/Display.html?id=121505
The problem lies in Math::BigInt::Calc. It tries to determine how large chunks to use when representing numbers internally. For instance, the number 112233445566778899 may be represented as [ 566778899, 112233445 ] on some systems, but as [ 6778899, 3344556, 1122 ] on others. When determining the largest chunk to use, the chunk size is increased until the test fails. The test is performed without "use integer" and then with "use integer". When "use integer" is in effect, and the test fails, perl crashes. The test needs to be fixed to avoid this problem.