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

[perl #117989] Stop Carp from pulling the caller's namespace

From:
Brian Fraser
Date:
May 13, 2013 19:58
Subject:
[perl #117989] Stop Carp from pulling the caller's namespace
Message ID:
rt-3.6.HEAD-2650-1368475101-1600.117989-75-0@perl.org
# New Ticket Created by  Brian Fraser 
# Please include the string:  [perl #117989]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117989 >


This is a bug report for perl from fraserbn@gmail.com,
generated with the help of perlbug 1.39 running under perl 5.16.2.


-----------------------------------------------------------------
[Please describe your issue here]

In perl 5.6, this:

perl -MCarp -le 'package Foo; eval { Carp::croak(1) }; print keys %Foo::;'

Used to output 'ISA'. In 5.8 and newer, it outputs "ISA" and "CARP_NOT".
This is because Carp::trusts_directly() simply tries using both
of those variables without checking if they exists first, which
ends up creating them.
The first of the attached patches fixes that so that no new globs are
introduced to the caller's namespace, by checking if the variable
exists in the stash before using them.

The second patch fixes a related issue:

    use Carp;
    package Foo;
    $CARP_NOT = 1;
    warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';
    eval { Carp::croak(1) };
    warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';

Both should display "undefined", but instead the second warn
shows that the array slot got vivified by Carp.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=low
    module=Carp
---
Site configuration information for perl 5.16.2:

Configured by hugmeir at Mon Feb 11 17:35:33 ART 2013.

Summary of my perl5 (revision 5 version 16 subversion 2) configuration:

  Platform:
    osname=darwin, osvers=12.2.1, archname=darwin-thread-multi-2level
    uname='darwin airtiger 12.2.1 darwin kernel version 12.2.1: thu oct 18
12:13:47 pdt 2012; root:xnu-2050.20.9~1release_x86_64 x86_64 '
    config_args='-de
-Dprefix=/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2 -DDEBUGGING
-Dusethreads -Uversiononly -Accflags=-Wall -Wextra
-Aeval:scriptdir=/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -Wall -Wextra -DDEBUGGING
-fno-strict-aliasing -pipe -fstack-protector',
    optimize='-O3 -g',
    cppflags='-fno-common -DPERL_DARWIN -Wall -Wextra -DDEBUGGING
-fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.24)', gccosandvers=''
    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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector'
    libpth=/usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.16.2:
    /Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
/lib/perl5/darwin-thread-multi-2level
    /Users/hugmeir/.perlbrew/libs/perl-5.16.2@all/lib/perl5

/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/darwin-thread-multi-2level
    /Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2

/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/lib/5.16.2/darwin-thread-multi-2level
    /Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/lib/5.16.2
    .

---
Environment for perl 5.16.2:
    DYLD_LIBRARY_PATH=/usr/local/mysql/lib:
    HOME=/Users/hugmeir
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
/bin:/Users/hugmeir/perl5/perlbrew/bin:/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/mysql/bin
    PERL5LIB=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all/lib/perl5
    PERLBREW_BASHRC_VERSION=0.58
    PERLBREW_HOME=/Users/hugmeir/.perlbrew
    PERLBREW_LIB=all
    PERLBREW_MANPATH=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
/man:/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/man
    PERLBREW_PATH=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
/bin:/Users/hugmeir/perl5/perlbrew/bin:/Users/hugmeir/perl5/perlbrew/perls/perl-5.16.2/bin
    PERLBREW_PERL=perl-5.16.2
    PERLBREW_ROOT=/Users/hugmeir/perl5/perlbrew
    PERLBREW_VERSION=0.58
    PERL_BADLANG (unset)
    PERL_LOCAL_LIB_ROOT=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
    PERL_MB_OPT=--install_base /Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
    PERL_MM_OPT=INSTALL_BASE=/Users/hugmeir/.perlbrew/libs/perl-5.16.2@all
    SHELL=/bin/bash



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