develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #119863] bug in Math::BigInt with undef

Thread Next
Henning Brauer
September 19, 2013 04:51
Re: [perl #119863] bug in Math::BigInt with undef
Message ID:
* Father Chrysostomos via RT <> [2013-09-17 17:38]:
> On Tue Sep 17 07:23:11 2013, wrote:
> > Math::BigInt got broken when one component is undef. Unfortunately
> > the I can only reproduce teh bug in a big custome webapp, but it
> > comes down to's objectify() being called with an undef
> > param, which it won't objectify, due to the check on line 2673ff
> > 
> >         # Don't do anything with undefs.
> > 
> >         unless (defined($a[$i])) {
> >             next;
> >         }
> That appears to be by design.  I suspect your code is buggy in giving it
> undef to begin with.

no, it is not, your statement last not least contradicts perlop:

    "undef" is always treated as numeric, and in particular is
    changed to 0 before incrementing (so that a post-increment of
    an undef value will return 0 rather than "undef").

and this has worked for ages, up until the upgrade to OpenBSD 5.4 and
thus perl 5.16.3.

the bug was introduced in;3Cf4c372?hp=7833bfdd94cb7b5afbbc1b18e75e664482f529d5

the trigger is sth like

my %foo;
$foo{nonexistantmember} += $somenumber;

that code is under "use warnings;" and doesn't trigger any, fwiw.

> Could you try to reduce your big webapp to something smaller that can
> reproduce the bug?

I tried, of course, but haven't been able to, i must miss some bit
that gets to that codepath. it should be obvious enough tho.

Henning Brauer,,
BS Web Services GmbH, AG Hamburg HRB 128289,
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About