Skip Menu |
Report information
Id: 119863
Status: rejected
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: hb-perlbug [at] bsws.de
Cc:
AdminCc:

Operating System: openbsd
PatchStatus: (no value)
Severity: High
Type:
Perl Version: 5.16.3
Fixed In: (no value)



Subject: bug in Math::BigInt with undef
Date: Tue, 17 Sep 2013 16:22:44 +0200
To: perlbug [...] perl.org
From: hb-perlbug [...] bsws.de
Download (untitled) / with headers
text/plain 4.4k
This is a bug report for perl from hb-perlbug@bsws.de, generated with the help of perlbug 1.39 running under perl 5.16.3. ----------------------------------------------------------------- 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; } callers, i. e. badd(), don't deal with any component being undef. sub badd { # add second arg (BINT or string) to first (BINT) (modifies first) # return result as BINT # set up parameters my ($self,$x,$y,@r) = (ref($_[0]),@_); # objectify is costly, so avoid it if ((!ref($_[0])) || (ref($_[0]) ne ref($_[1]))) { ($self,$x,$y,@r) = objectify(2,@_); } return $x if $x->modify('badd'); return $upgrade->badd($upgrade->new($x),$upgrade->new($y),@r) if defined $upgrade && ((!$x->isa($self)) || (!$y->isa($self))); in my case $y ends up being undef, objectify doesn't do anything to it, and the $y->isa call chokes. [error] Can't call method "isa" on an undefined value at /usr/libdata/perl5/Math/BigInt.pm line 1131.\n crude (and almost certainly not correct) fix: --- BigInt.pm.orig Tue Sep 17 10:37:09 2013 +++ BigInt.pm Tue Sep 17 10:32:12 2013 @@ -2670,11 +2670,12 @@ sub objectify { next; } - # Don't do anything with undefs. - - unless (defined($a[$i])) { - next; - } +# # Don't do anything with undefs. +# +# unless (defined($a[$i])) { +# next; +# } + $a[$i] //= 0; # Perl scalars are fed to the appropriate constructor. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=library severity=high module=Math::BigInt --- Site configuration information for perl 5.16.3: Configured by root at Thu Jan 1 0:00:00 UTC 1970. Summary of my perl5 (revision 5 version 16 subversion 3) configuration: Platform: osname=openbsd, osvers=5.4, archname=amd64-openbsd uname='openbsd' config_args='-dsE -Dopenbsd_distribution=defined -Dccflags=-DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -Dmksymlinks' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -fstack-protector -I/usr/local/include', optimize='-O2', cppflags='-DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -fno-delete-null-pointer-checks -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.2.1 20070719 ', gccosandvers='openbsd5.4' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-E -fstack-protector' libpth=/usr/lib libs=-lm -lutil -lc perllibs=-lm -lutil -lc libc=/usr/lib/libc.a, so=so, useshrplib=true, libperl=libperl.so.14.0 gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-R/usr/libdata/perl5/amd64-openbsd/5.16.3/CORE' cccdlflags='-DPIC -fPIC ', lddlflags='-shared -fPIC -fstack-protector' Locally applied patches: --- @INC for perl 5.16.3: /usr/local/libdata/perl5/site_perl/amd64-openbsd /usr/libdata/perl5/site_perl/amd64-openbsd /usr/local/libdata/perl5/site_perl /usr/libdata/perl5/site_perl /usr/libdata/perl5/amd64-openbsd/5.16.3 /usr/local/libdata/perl5/amd64-openbsd/5.16.3 /usr/libdata/perl5 /usr/local/libdata/perl5 . --- Environment for perl 5.16.3: HOME=/home/brahe LANG (unset) LANGUAGE (unset) LC_CTYPE=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/brahe/bin:/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/local/sbin PERL_BADLANG (unset) SHELL=/bin/ksh
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 654b
On Tue Sep 17 07:23:11 2013, hb-perlbug@bsws.de wrote: Show quoted text
> 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. Could you try to reduce your big webapp to something smaller that can reproduce the bug? -- Father Chrysostomos
CC: hb-perlbug [...] bsws.de
Subject: Re: [perl #119863] bug in Math::BigInt with undef
Date: Tue, 17 Sep 2013 17:46:54 +0200
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
From: Henning Brauer <hb [...] bsws.de>
Download (untitled) / with headers
text/plain 1.6k
* Father Chrysostomos via RT <perlbug-followup@perl.org> [2013-09-17 17:38]: Show quoted text
> 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. Show quoted text
> 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
Date: Fri, 15 Dec 2017 05:59:16 +0000
To: perl5-porters [...] perl.org
Subject: Re: [perl #119863] bug in Math::BigInt with undef
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 262b
Math-BigInt is maintained primarily as a CPAN distribution, so this is the wrong place to report bugs in it. If the problem described still occurs, you should report it to <bug-Math-BigInt@rt.cpan.org>. This ticket in the perl5 queue should be closed. -zefram


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org