Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1609708

Summary: Mishandling of undef values in Math::BigInt
Product: Red Hat Enterprise Linux 7 Reporter: Ted Rule <ejtr>
Component: perlAssignee: perl-maint-list
Status: CLOSED NEXTRELEASE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.4CC: ppisar
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Executing a Perl code where undef value is compared to a big integer. Consequence: The program is aborted with a message about calling "isa" method "isa" on undef value. Fix: A fix was ported from Math-BigInt upstream. Result: undef value is now correctly coerced to MathBig::Int or MathBig::Float as needed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-21 16:18:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Attempt to correct Math::BigInt::objectify() handling of undef
none
Fix ported from Math-BigInt-1.9995 none

Description Ted Rule 2018-07-30 08:30:51 UTC
Created attachment 1471448 [details]
Attempt to correct Math::BigInt::objectify() handling of undef

Description of problem:

When using the bignum library which auto-loads Math::BigInt so as to overload various operators, the automatic promotion of plain integers to Math::BigInt objects results in die() as it attempts to perform isa() on an undef.


Version-Release number of selected component (if applicable):

5.16.3-292.el7 

where Math::BigInt itself is version 1.998

How reproducible:

Perform a simple math operation using an undefined value with the bignum library loaded. We that string operators don't appear to trigger the fault.

Steps to Reproduce:

$ perl -e 'use bignum; printf "%d\n", ( undef == 0 );'
Can't call method "isa" on an undefined value at /usr/share/perl5/Math/BigInt.pm line 1058.
$ 

$ perl -e 'printf "%d\n", ( undef == 0 );'
1

$ perl -e 'use bignum; printf ":%s:\n", ( undef eq 0 );'
::
$ 



Actual results:

Can't call method "isa"

Expected results:

1

Additional info:

The overall problem appears to hinge on how the objectify() method in Math::BigInt converts an undefined value to something which the rest of the library can use without error.

To that end, I've patched my local copy to convert "undef" to Math::BigInt->new(undef) within objectify()

Whilst my patch appears to fixup the localised problem, it should be noted that the current CPAN version of Math::BigInt has significant revisions which probably also fixup this as well as many other issues, judging by the Changelog therein.

Note also that the mishandling of undef appears to only have appeared in recent versions of the Perl RPM under RHEL7. The version of Math::BigInt in Perl under RHEL6 appear to be immune as it effectively converts "undef" to Math::BigInt->new(undef) in objectify() at a slightly different point in the code path.

Comment 2 Petr Pisar 2018-07-30 09:08:39 UTC
Thank you for the report. I can reproduce it and I agree it's a bug.

You wrote "the mishandling of undef appears to only have appeared in recent versions of the Perl RPM under RHEL7". But according to my tests even the first RHEL-7 release (perl-5.16.3-283.el7.x86_64) behaved like this. Can you tell me what RHEL-7 perl version works for you?

If this issue is important for you, please contact Red Hat support.

Comment 3 Ted Rule 2018-07-30 09:29:42 UTC
My apologies; perhaps that comment was badly worded. I meant that the problem only surfaced on our machines in RHEL7, whilst I could see that RHEL6 seemed to be Ok. I hadn't explicitly checked all the different versions of Perl RPM. The CPAN referenced bug does seem to be the very same thing, with a very similar suggested fix.

Comment 4 Petr Pisar 2018-07-30 11:32:50 UTC
Created attachment 1471505 [details]
Fix ported from Math-BigInt-1.9995

Comment 5 Petr Pisar 2018-07-30 11:45:26 UTC
How to test:

(1) Install perl
(2) Check undef with a big integer:
    $ perl -we 'use bignum; my $a = 2 + undef; print qq{$a\n}'
    Before: An error is reported and the program dies:
Can't call method "isa" on an undefined value at /usr/share/perl5/Math/BigInt.pm line 1131.
    After: 2 is reported on standard output.
(3) Check undef with a big float:
    $ perl -we 'use bignum; my $a = 2.1 + undef; print qq{$a\n}'
    Before: Although the program works, some warnings are reported:
Use of uninitialized value in pattern match (m//) at /usr/share/perl5/Math/BigFloat.pm line 710.
Use of uninitialized value in string eq at /usr/share/perl5/Math/BigFloat.pm line 713.
Use of uninitialized value in pattern match (m//) at /usr/share/perl5/Math/BigFloat.pm line 722.
2.1
    After: No warning is reported, 2.1 is reported on standard output.

Comment 6 Petr Pisar 2019-11-21 16:18:27 UTC
Red Hat does not plan to fix this issue in Red Hat Enterprise Linux 7. If this issue is critical for you, please contact Red Hat support.
Please also consider moving to Red Hat Enterprise Linux 8 that provides perl-bignum-0:0.49-2.el8 package (from Perl 5.26) that contains the requested fix.