develooper Front page | perl.perl5.porters | Postings from April 2001

[ID 20010426.005] Magic not being removed at scope exit

Thread Next
From:
Graham Barr
Date:
April 26, 2001 14:33
Subject:
[ID 20010426.005] Magic not being removed at scope exit
Message ID:
200104262131.f3QLVrN73410@monty.mutatus.co.uk

This is a bug report for perl from gbarr@monty.mutatus.co.uk,
generated with the help of perlbug 1.33 running under perl v5.7.1.


-----------------------------------------------------------------
[Please enter your report here]

The following script shows a bug that magic is not being removed from $_
at the exit of bnorm(). This only happens if the s/// matches and the
replacement contains a $1..$n variable

use Devel::Peek;

sub bnorm { #(num_str) return num_str
  local($_) = @_;
  s/(\d)/$1/;
}

sub doit {
  print "-"x30,"\n";
  my $num = (1<<17) * (1<<17);
  print "$num\n";
  {
   local $_ = $num;
   print "$_\n";
  }
}

doit();
Devel::Peek::Dump($_);
bnorm("1092509802939879587398450394850984098031948509");
Devel::Peek::Dump($_);
doit();


Sample output


------------------------------
17179869184
17179869184
SV = NULL(0x0) at 0x8157108
  REFCNT = 1
  FLAGS = ()
SV = PVMG(0x817f140) at 0x8157108
  REFCNT = 1
  FLAGS = (SMG)
  IV = 0
  NV = 0
  PV = 0
  MAGIC = 0x8181620
    MG_VIRTUAL = &PL_vtbl_mglob
    MG_TYPE = 'g'
    MG_LEN = -1
------------------------------
17179869184
4294967295


this bug arises in Math::BigInt if a M:BI is compare to a normal scalar that
contains a value which is too big for an IV, eg

use Math::BigInt;
my $num = (1<<17) * (1<<17);
my $bi = Math::BigInt->new("$num");
die unless $bi == ((1<<17) * (1<<17));


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.7.1:

Configured by gbarr at Tue Apr 10 06:55:54 BST 2001.

Summary of my perl5 (revision 5.0 version 7 subversion 1) configuration:
  Platform:
    osname=freebsd, osvers=4.2-release, archname=i386-freebsd
    uname='freebsd monty.mutatus.co.uk 4.2-release freebsd 4.2-release #4: mon apr 9 12:01:50 bst 2001 root@monty.mutatus.co.uk:usrsrcsyscompilemutatus i386 '
    config_args='-d -e -r -D cc=gcc -D optimize=-O2 -g -D prefix=/opt/perl-5.7.1 -Dusedevel'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include',
    optimize='-O2 -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lbind -lgdbm -ldb -lm -lc -lcrypt -liconv -lutil
    perllibs=-lbind -lm -lc -lcrypt -liconv -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.7.1:
    /opt/perl-5.7.1/lib/5.7.1/i386-freebsd
    /opt/perl-5.7.1/lib/5.7.1
    /opt/perl-5.7.1/lib/site_perl/5.7.1/i386-freebsd
    /opt/perl-5.7.1/lib/site_perl/5.7.1
    /opt/perl-5.7.1/lib/site_perl
    .

---
Environment for perl v5.7.1:
    HOME=/home/gbarr
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/krb5/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/X11R6/bin:/home/gbarr/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh


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