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

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

Thread Next
From:
Henning Brauer
Date:
September 19, 2013 04:51
Subject:
Re: [perl #119863] bug in Math::BigInt with undef
Message ID:
20130917154654.GO11447@quigon.bsws.de
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2013-09-17 17:38]:
> On Tue Sep 17 07:23:11 2013, hb-perlbug@bsws.de 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 BigInt.pm'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
http://perl5.git.perl.org/perl.git/commitdiff/66a0495875e8130c45cac4fabd5f8d05f2;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, hb@bsws.de, henning@openbsd.org
BS Web Services GmbH, AG Hamburg HRB 128289, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About