Skip Menu | You are currently an anonymous guest. | Login | Return to Main | Preferences
Id: 23578
Status: resolved
Left: 0 min
Priority: 0/0
Queue: perl5

Owner: Nobody
Requestors: perlbug [at] coppit.org
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: low
Type: wontfix
Perl Version: 5.8.0
Fixed In: (no value)



X History Display mode: Brief headersFull headers
#   Mon Aug 25 12:12:56 2003 perlbug@coppit.org - Ticket created  
Date: Thu, 21 Aug 2003 13:41:46 -0400 (EDT)
From: David Coppit <perlbug@coppit.org>
To: perlbug@perl.com
Subject: Symbol::delete_package permanently deletes namespace
Download (untitled) [text/plain 3.7k]
This is a bug report for perl from perlbug@coppit.org,
generated with the help of perlbug 1.34 running under perl v5.8.0.


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

When running the following script,

use Symbol;

require Storable;
Symbol::delete_package('Storable');

# Delete everything just to be safe.
map { delete $INC{$_} } keys %INC;

require Storable;
Storable::freeze([1,2,3]);

I get the following error:

Undefined subroutine &Storable::freeze called at test.pl line 12.

I was expecting the freeze function to be available after require'ing
Storable the second time. (i.e. no error)



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

Configured by bhcompile at Sun Sep 1 23:55:07 EDT 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.18-11smp, archname=i386-linux-thread-multi
uname='linux daffy.perf.redhat.com 2.4.18-11smp #1 smp thu aug 15 06:41:59 edt 2002 i686 i686 i386 gnulinux '
config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2 -march=i386 -mcpu=i686',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/include/gdbm'
ccversion='', gccversion='3.2 20020822 (Red Hat Linux Rawhide 3.2-5)', 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, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.2.92.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.2.92'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:


---
@INC for perl v5.8.0:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
.

---
Environment for perl v5.8.0:
HOME=/home/david
LANG=en_US
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/david/bin
PERLDB_OPTS=HighBit=1
PERL_BADLANG (unset)
SHELL=/bin/bash
#   Mon Aug 25 12:13:00 2003 RT_System - Default: Keyword/9 changed from (no value) to 'Linux'  
#   Mon Aug 25 12:13:00 2003 RT_System - Default: Keyword/11 changed from (no value) to 'low'  
#   Mon Aug 25 12:13:01 2003 RT_System - Default: Keyword/12 changed from (no value) to 'core'  
#   Mon Aug 25 12:13:01 2003 RT_System - Default: Keyword/13 changed from (no value) to '5.8.0'  
#   Tue Aug 26 03:02:50 2003 rafael - Correspondence added  
Date: Tue, 26 Aug 2003 11:52:55 +0200
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
To: perl5-porters@perl.org
Subject: Re: [perl #23578] Symbol::delete_package permanently deletes namespace
Download (untitled) [text/plain 1.5k]
David Coppit (via RT) wrote:
>
> When running the following script,
>
> use Symbol;
>
> require Storable;
> Symbol::delete_package('Storable');
>
> # Delete everything just to be safe.
> map { delete $INC{$_} } keys %INC;
>
> require Storable;
> Storable::freeze([1,2,3]);
>
> I get the following error:
>
> Undefined subroutine &Storable::freeze called at test.pl line 12.
>
> I was expecting the freeze function to be available after require'ing
> Storable the second time. (i.e. no error)

I will try to explain what I think is happening here with a simpler
example :

Let x.pl contain :

use Symbol;
Symbol::delete_package('A');
require A;
A::foo();

And A.pm defining a single subroutine :

package A;
sub foo {print "foo\n"}
1;

When x.pl is compiled, the %A:: stash is created to put an empty
placeholder for the foo() subroutine, at compile time. This placeholder
is supposed to be replaced by the actual subroutine when A is loaded (at
runtime, since we use "require A".)

However the placeholder is wiped out by delete_package(), and loading
A.pm recreates a new A stash, but not necessarily with A::foo at the same
memory address. And the original A::foo() call in x.pl has already been
optimized to a glob pointer, since perl is smart enough to avoid a stash
lookup each time it calls a subroutine. This glob has been undefined
by delete_package().

And indeed, changing the A::foo() call to
&{"A::foo"}();
makes it work, because this forces the symbolic lookup.

I don't know how to fix this.
#   Wed Aug 27 14:09:22 2003 rafael - Correspondence added  
Date: Wed, 27 Aug 2003 23:15:38 +0200
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
To: perl5-porters@perl.org
Subject: Re: [perl #23578] Symbol::delete_package permanently deletes namespace
Download (untitled) [text/plain 301b]
Rafael Garcia-Suarez wrote:
>
> I will try to explain what I think is happening here with a simpler
> example :

I've now added a BUGS section to the docs for Symbol about this
overpowerful effect of delete_package(). While I was at it, I added
some tests for this function as well. (change 20922.)
#   Wed Aug 27 14:10:43 2003 rafael - Status changed from 'new' to 'resolved'  
#   Wed Aug 27 14:10:45 2003 rafael - Default: Keyword/12 changed from (no value) to 'wontfix'  
#   Wed Aug 27 14:10:45 2003 rafael - Default: Keyword/ changed from 'core' to ''  


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