This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #73534] Bigrat segfaults on irrational numbers
authorFather Chrysostomos <sprout@cpan.org>
Tue, 5 Oct 2010 06:04:44 +0000 (23:04 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 5 Oct 2010 06:05:59 +0000 (23:05 -0700)
commit45029d2dbcc918ee10234beaf6a38744ad61567e
treeda5557fd6d5b48c27ccf793368418a27265b782c
parent733a5566738583595dfc3a5d95e1229a3bfda72f
[perl #73534] Bigrat segfaults on irrational numbers

aka [rt.cpan.org #55767] segfault on sqrt(2) with bigrat

The problem seems to be in &Math::BigInt::objectify. It doesn’t try to
convert the number object into the right class if $upgrade is defined.
The attached patch changes it to make sure it belongs to the calling
class or to the $upgrade class.

Here is a ‘one’-liner to trigger the same bug without bigrat:

perl -Ilib -MMath::BigInt=upgrade,Math::BigFloat \
 -MMath::BigFloat=upgrade,Math::BigMouse -le \
 '@Math::BigMouse::ISA = Math::BigFloat; print sqrt Math::BigInt->new(2)'
MANIFEST
dist/Math-BigInt/lib/Math/BigInt.pm
dist/Math-BigInt/t/upgrade2.t [new file with mode: 0644]
pod/perldelta.pod