Re: [perl #56608] Math::BigInt gives completely when Math::BigInt::GMP is used
by Tels other posts by this author
Jul 5 2008 1:58AM messages near this date
Re: [perl #56608] Math::BigInt gives completely when Math::BigInt::GMP is used
|
[perl #56606] 5.10.0 crash on serialised v-strings
On Saturday 05 July 2008 10:50:59 you wrote:
> On Saturday 05 July 2008 10:28:54 Bram wrote:
> > Citeren Marc Lehmann <perlbug-followup@[...].org>:
> > > -----------------------------------------------------------------
> > > [Please enter your report here]
> > >
> > > When Math::BigInt uses GMP as backend, it gives completely bogus
> > > results:
> > >
> > > perl -MMath::BigInt=lib,GMP -e 'my $b = 0xc0010203; my $m =
> > > Math::BigInt->new (2) ** 24 - 1; warn $m + $b'
> > > -105689855 at -e line 1.
> > >
> > > perl -MMath::BigInt=lib,GMP -e 'my $b = 0xc0010203; my $m =
> > > Math::BigInt->new (2) ** 32 - 1; warn $m + $b'
> > > 3221291522 at -e line 1.
> > >
> > > This only seems to happen with 32-bit perls.
>
> I am pretty sure that is because the value is in-between treated as
> signed vs. unsigned integer and thus arrives wrongly in libgmp.
>
> Can you please run:
>
> perl -Mbignum,l,GMP=v
Sorry,
perl -Mbignum=l,GMP,v
But I think I found the bug, GMP,xs contains:
if (SvUOK(x))
{
mpz_init_set_si(*RETVAL, (UV)SvUV(x));
}
else
{
...
That should probably be:
if (SvUOK(x))
{
mpz_init_set_ui(*RETVAL, (UV)SvUV(x)); // _ui to fix [perl #56608]
}
else
{
...
Marc, could you please patch, recompile and test with this and see if it
resolves it? I only have a 64bit Perl on this machine.
All the best,
Tels
--
Signed on Sat Jul 5 10:54:34 2008 with key 0x93B84C15.
Get one of my photo posters: http://bloodgate.com/posters
PGP key on http://bloodgate.com/tels.asc or per email.
"In my opiniation, "burglarize" is a perfectionally validative
wordification. How else would reportization of the securitial/policial
forceship appearize to be importantive enoughly to be respectative by
the massmediaship and influentate the societyness?"
-- SharpFang (651121) on 2004-12-13 at /. about "burgle"
vs. "burglarize"
Thread:
Marc Lehmann
Bram
Matt Kraai
Tels
Tels
|