Deep recursion on subroutine
darkblaze69 opened this issue · comments
After upgrading from perl 5.36 to perl 5.38 I get this error:
$ ipcalc -r 172.18.10.32-172.18.10.33
deaggregate 172.18.10.32 - 172.18.10.33
Deep recursion on subroutine "Math::BigInt::bior" at /usr/share/perl5/core_perl/Math/BigFloat.pm line 3883.
Deep recursion on subroutine "Math::BigFloat::bior" at /usr/share/perl5/core_perl/Math/BigInt.pm line 3513.
This appears to be caused by a change to bitshift operations in Math::BigInt included in 5.38 causing the deaggregate function in https://github.com/kjokjo/ipcalc/blob/master/ipcalc#L694 to loop forever.
See https://rt.cpan.org/Public/Bug/Display.html?id=149932 and Perl/perl5#21518
Actually this happens due to a different bug when comparing BigInts to BigFloats, which was first introduced in Math:BigInt 1.999840 and fixed in 1.999842.
In 2022 another bug in bitwise comparisons had already broken ipcalc, also causing an infinite recursion (Debian bug, CPAN bug) but was fixed in 1.999838.
I don’t know the inner workings of the ipcalc
utility, but if it is possible, I recommend using bigint
or bigfloat
instead of bignum
. If you are doing integer arithmetic only, then use bigint
. If you need floating point numbers, then use bigfloat
.
The bignum
module does automatic upgrading and downgrading between Math::BigInt
and Math::BigFloat
. Not only does this introduce overhead, but the upgrading and downgrading has never been fully implemented. I have tried to finish what the original author never completed, but unfortunately, there have been some hiccups along the way.