Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep recursion on subroutine #15

Open
darkblaze69 opened this issue Aug 4, 2023 · 2 comments
Open

Deep recursion on subroutine #15

darkblaze69 opened this issue Aug 4, 2023 · 2 comments

Comments

@darkblaze69
Copy link

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.
@LeoVerto
Copy link

LeoVerto commented Oct 25, 2023

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.

LeoVerto added a commit to LeoVerto/ipcalc that referenced this issue Oct 25, 2023
Workaround for a bug causing an infinite loop when comparing a
BigInt to a BigFloat, introduced in Math::BigInt 1.999840 and
fixed in 1.999842.

See pjacklam/p5-Math-BigInt@d268562

Fixes kjokjo#15, fixes kjokjo#17.
LeoVerto added a commit to LeoVerto/ipcalc that referenced this issue Oct 25, 2023
Workaround for a bug causing an infinite recursion when comparing
a BigInt to a BigFloat, introduced in Math::BigInt 1.999840 and
fixed in 1.999842.

See pjacklam/p5-Math-BigInt@d268562

Fixes kjokjo#15, fixes kjokjo#17.
@pjacklam
Copy link

pjacklam commented Dec 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants