Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting stashes causes SEGVs #3438

Closed
p5pRT opened this issue Feb 19, 2001 · 26 comments
Closed

Deleting stashes causes SEGVs #3438

p5pRT opened this issue Feb 19, 2001 · 26 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 19, 2001

Migrated from rt.perl.org#5851 (status was 'resolved')

Searchable as RT5851$

@p5pRT
Copy link
Author

p5pRT commented Feb 19, 2001

From @AlanBurlison

If you delete a stash and then try to call something it it you get a SEGV.
Hardly surprising I suppose, but perhaps something should be done about it
sometime.

$ perl -e 'sub bang { print "bang!\n"; } undef %main​::; bang;'
Segmentation Fault(coredump)

$ pstack core
core 'core' of 103834​: /usr/local/bin/perl -e sub bang { print "bang!\n"; } undef %main​::; bang;'
ff27ca34 Perl_hv_fetch (2e9a0, ffbee6f0, b, 0, a2411bd1, 2d948) + 16c
ff229874 Perl_gv_fetchpv (b, 0, 3a, 0, 2d348, ff30ac24) + 160
ff229430 Perl_gv_stashpvn (ff2f37e8, ffbee850, 0, ff2f37e8, 9, 3a535550) + 60
ff228d6c Perl_gv_fetchmeth (a, 36174, 7, 0, ff30ac24, 3606c) + 4ac
ff229054 Perl_gv_fetchmethod_autoload (3606c, 3606c, 7, ff30ac24, ff2f86f8, 1) + 160
ff295660 Perl_sv_clear (2faf4, 1000, 34770, ff0b6000, 22994, ff0419f8) + b4
ff296010 Perl_sv_free (360e4, ff30ac24, 0, 1c, 2296c, ff276190) + 1c0
ff22b220 Perl_gp_free (36a08, 360f0, d, 600d, 22994, ff0419f8) + 130
ff295bc8 Perl_sv_clear (0, 1000, c, 0, 2296c, ff27ef34) + 61c
ff296010 Perl_sv_free (360f0, ff30ac24, 360f0, ff30ac24, 2e968, 32f2c) + 1c0
ff27e5b0 Perl_hv_free_ent (2d948, 34080, ff3a0414, 0, ff3e2698, ff20e503) + 94
ff27e7ec S_hfreeentries (1f, 363c8, 7c, 1f, 33db0, 2d948) + 4c
ff27e840 Perl_hv_undef (2e9a0, 2d948, 2000000b, 0, 0, 0) + 14
ff29efb8 Perl_pp_undef (2d49c, 2d4a0, ff30ac24, 2faf4, 2d948, 2faf4) + 13c
ff2822d8 Perl_runops_standard (ff30ac24, 2d49c, ffbeeecc, 0, ff3e2698, 11572) + 44
ff222940 S_run_body (1, ff31b494, ff30ac24, ff317090, ff30ac24, ff31b648) + 1dc
ff222564 perl_run (2d4d0, 11b94, 3, ffbeefec, 0, 3) + 2a0
00011b44 main (0, 2d330, 2cd08, ffbeefec, 0, 0) + 9c
00011a80 _start (0, 0, 0, 0, 0, 0) + b8

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.6.0:

Configured by alanbur at Tue May 23 19:20:13 BST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris-64int
    uname='sunos mower 5.8 generic sun4u sparc sunw,ultra-60 '
    config_args='-dsOE -Dprefix=/usr/local -Dinstallprefix=/usr/local -Dsiteprefix=/usr/local -Doptimize=-xO3 -Duseshrplib -Uusemymalloc -Ubincompat5005 -Duse64bitint -Accflags=-DDL_UNLOAD_ALL_AT_EXIT'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-xO3', gccversion=
    cppflags='-DDL_UNLOAD_ALL_AT_EXIT'
    ccflags ='-DDL_UNLOAD_ALL_AT_EXIT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/opt/SUNWspro/SC5.0/lib '
    libpth=/opt/SUNWspro/SC5.0/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt -lsec
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -R /usr/local/lib/perl5/5.6.0/sun4-solaris-64int/CORE'
    cccdlflags='-KPIC', lddlflags='-G -L/opt/SUNWspro/SC5.0/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/sun4-solaris-64int
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/sun4-solaris-64int
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home1/homedir/alanbur
    LANG=C
    LANGUAGE (unset)
    LC_COLLATE=en_GB.ISO8859-1
    LC_CTYPE=en_GB.ISO8859-1
    LC_MESSAGES=C
    LC_MONETARY=en_GB.ISO8859-1
    LC_NUMERIC=en_GB.ISO8859-1
    LC_TIME=en_GB.ISO8859-1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home1/homedir/alanbur/bin:/home1/homedir/alanbur/bin/sparc:/usr/bin:/usr/sbin:/usr/local/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ccs/bin:/opt/SUNWspro-local/bin:/usr/dist/exe:/usr/dist/local/exe:/home1/homedir/alanbur/perforce:/home1/homedir/oracle/product/8.1.6/bin
    PERL_BADLANG (unset)
    SHELL=/bin/ksh

@p5pRT
Copy link
Author

p5pRT commented Feb 19, 2001

From @Tux

On Mon, 19 Feb 2001 11​:23​:53 GMT, alanbur@​mower.uk.sun.com wrote​:

This is a bug report for perl from alanbur@​mower.uk.sun.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.

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

If you delete a stash and then try to call something it it you get a SEGV.
Hardly surprising I suppose, but perhaps something should be done about it
sometime.

$ perl -e 'sub bang { print "bang!\n"; } undef %main​::; bang;'
Segmentation Fault(coredump)

Should we allow to delete/undef %​:: (%main​::) anytime at all?

@p5pRT
Copy link
Author

p5pRT commented Feb 19, 2001

From @simoncozens

On Mon, Feb 19, 2001 at 05​:12​:27PM +0100, H. Merijn Brand wrote​:

$ perl -e 'sub bang { print "bang!\n"; } undef %main​::; bang;'
Segmentation Fault(coredump)

Should we allow to delete/undef %​:: (%main​::) anytime at all?

I would say yes, on the "stupid things possible" principle or whatever
it is. But I don't know what decent behaviour in the above case would be.
I think it would be easy enough to croak with a "sub has gone away" type
rror.

Simon

@p5pRT
Copy link
Author

p5pRT commented Feb 19, 2001

From @AlanBurlison

"H.Merijn Brand" wrote​:

Should we allow to delete/undef %​:: (%main​::) anytime at all?

I suspect undef of any stash with a sub in it that is subsequently
called will do the same thing - main​:: isn't special in that respect. I
guess what *should* happen is that stash deletion should invalidate the
method cache, and a subsequent attempt to call the sub should fail with
'sub not defined' or somesuch.

Alan Burlison

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2001

From [Unknown Contact. See original ticket]

Alan Burlison <Alan.Burlison@​uk.sun.com> writes​:

"H.Merijn Brand" wrote​:

Should we allow to delete/undef %​:: (%main​::) anytime at all?

I suspect undef of any stash with a sub in it that is subsequently
called will do the same thing - main​:: isn't special in that respect. I
guess what *should* happen is that stash deletion should invalidate the
method cache, and a subsequent attempt to call the sub should fail with
'sub not defined' or somesuch.

Well I get a stack dump with ACCVIO (equiv of SEGV) from just​:

  $ perl -e"sub foo{print 'hi';} undef %main​::;"

(note no attempt to call the sub)

But
  $ perl -e"sub BAR​::foo{print 'hi';} undef %BAR​::; BAR​::foo();"
  hi
seems not only to not ACCVIO, but also fails to delete the sub (also
true if the definition of BAR​::foo is in a module with "package BAR;..."
type definitions.)

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2001

From @AlanBurlison

Charles Lane wrote​:

But
$ perl -e"sub BAR​::foo{print 'hi';} undef %BAR​::; BAR​::foo();"
hi
seems not only to not ACCVIO, but also fails to delete the sub (also
true if the definition of BAR​::foo is in a module with "package BAR;..."
type definitions.)

This is because of the refcount loop between a CV (code block) and its
parent GV (glob). At present subs are effectively immortal because of
this loop. If you look back over my other recent mails you'll see I've
wittered on at length about this.

I'm currently working on fixing this, but the fix has uncovered a really
nasty bug in the scoping of %^H, which I'm currently trying to track
down.

Alan Burlison

@p5pRT
Copy link
Author

p5pRT commented Jun 19, 2001

From gt4556a@prism.gatech.edu

undef()ing the symbol table of package main causes coredumps. The problem has
been reproduced on at least two version of Perl (5.00505 and 5.6.1, both on
SunOS) and two people (on different machines).

Test program​:

sub aaa {};
undef %​::;

Note that the coredump doesn't occur for certain names of the above sub.
Examples​:

* a
* aa
* b
* [try letters in between?]
* z
* za - zh

There are certainly more names. That don't trigger the coredump. Defining a
variable instead of a sub before undef()ing %​:: gives no coredump either.

Perl Info


Site configuration information for perl 5.00503:

Configured by willday at Fri Apr  2 11:27:26 EST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos rom 5.6 generic_105181-12 sun4u sparc sunw,ultra-1 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-fast', gccversion=
    cppflags=''
    ccflags =''
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-fast -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /fuse4/47/gt4556a/perl/sun4-solaris
    /fuse4/47/gt4556a/perl
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/fuse4/47/gt4556a
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/fuse4/47/gt4556a/local/bin:/usr/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/local/bin::/tnt1/38/gtwreck/bin:/fuse4/47/gt4556a/bin:/fuse4/47/gt4556a/local/bin:/fuse4/47/gt4556a/nmh/bin:/fuse4/47/gt4556a/nmh/lib:/tnt1/38/gtwreck/bin:/fuse4/47/gt4556a/bin:/fuse4/47/gt4556a/local/bin:/fuse4/47/gt4556a/nmh/bin:/fuse4/47/gt4556a/nmh/lib
    PERL5LIB=/fuse4/47/gt4556a/perl
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 10, 2004

From jeff@zeroclue.com

This is a bug report for perl from jeff@​zeroclue.com,
generated with the help of perlbug 1.35 running under perl v5.8.4.


Perl crashes (seg fault) when emptying the main namespace in any of the special blocks. I.E.

jeff@​pokey​:~ $ perl -e 'CHECK{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'BEGIN{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'END{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'INIT{%​::=()}'
Segmentation fault



Flags​:
  category=core
  severity=low


Site configuration information for perl v5.8.4​:

Configured by Debian Project at Sun Sep 26 12​:11​:30 CEST 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration​:
  Platform​:
  osname=linux, osvers=2.6.8-1-686, archname=i386-linux-thread-multi
  uname='linux cachaca 2.6.8-1-686 #1 sat aug 28 14​:11​:39 edt 2004 i686 gnulinux '
  config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.4 -Dsitearch=/usr/local/lib/perl/5.8.4 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.4 -Dd_dosuid -des'
  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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include'
  ccversion='', gccversion='3.3.4 (Debian 1​:3.3.4-12)', 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='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
  perllibs=-ldl -lm -lpthread -lc -lcrypt
  libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so.5.8.4
  gnulibc_version='2.3.2'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl v5.8.4​:
  /home/jeff/dts/base/lib
  /etc/perl
  /usr/local/lib/perl/5.8.4
  /usr/local/share/perl/5.8.4
  /usr/lib/perl5
  /usr/share/perl5
  /usr/lib/perl/5.8
  /usr/share/perl/5.8
  /usr/local/lib/site_perl
  .


Environment for perl v5.8.4​:
  HOME=/home/jeff
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LC_CTYPE=en_US.UTF-8
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/jeff/bin​:/usr/local/java/bin​:/home/jeff/dts/base/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/jeff/bin​:/usr/local/java/bin​:/home/jeff/dts/base/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/bin/X11​:/usr/games
  PERL5LIB=/home/jeff/dts/base/lib
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2004

From mjtg@cam.ac.uk

Jeff Lavallee <jeff@​zeroclue.com> wrote

Perl crashes (seg fault) when emptying the main namespace in any of
the special blocks. I.E.

jeff@​pokey​:~ $ perl -e 'CHECK{%​::=()}'
Segmentation fault

This is a variation on an old chestnut. To help track it down, I note

perl -we 'BEGIN { delete $​::{q(@​)}}'
Segmentation Fault

whereas

perl -w
BEGIN {
delete @​​::{
"ENV",
"CORE\​:\​:",
"\+",
"STDERR",
"STDOUT",
"\<none\>\​:\​:",
"\"",
"_\<perlmain\.c",
"DynaLoader\​:\​:",
"main\​:\​:",
"Internals\​:\​:",
"DATA",
"ARGV",
"\/",
"Regexp\​:\​:",
"\x12",
"UNIVERSAL\​:\​:",
"0",
"attributes\​:\​:",
"STDIN",
"_\<perlio\.c",
"IO\​:\​:",
"INC",
"\x18",
"DB\​:\​:",
"_\<universal\.c",
"PerlIO\​:\​:",
"_",
"_\<\-",
"\-",
"stdout",
"\x08",
"utf8\​:\​:",
"\$",
"_\<xsutils\.c",
"stderr",
"stdin",
}};
__END__

doesn't fail. That's all the other keys found by doing

perl -wle 'print foreach keys %​::'

So $@​ is the thing to stare at.

And as an extra data point (in case you haven't already guessed)

perl -we 'eval q(delete $​::{q(@​)})'
Segmentation Fault

Mike Guy

@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @rgs

Jeff Lavallee (via RT) wrote​:

Perl crashes (seg fault) when emptying the main namespace in any of the special blocks. I.E.

jeff@​pokey​:~ $ perl -e 'CHECK{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'BEGIN{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'END{%​::=()}'
Segmentation fault
jeff@​pokey​:~ $ perl -e 'INIT{%​::=()}'
Segmentation fault

And likewise

  $ perl -e 'eval{%​::=()}'
  Segmentation fault

There is a whole class of problems that come from this.
In this case, it's $@​ (or, internally, PL_errgv) being accessed _after_
it has been deleted.

A more general, but unclean, fix, would be to avoid deleting any GV in
%​:: that has the GvMULTI flag set. More clean, add a flag for "global
immortal" variables that should never be deleted from %​::. I don't know
where to find room for flags, though. Opinions ?

--
--Metempsychosis?
--Yes. Who's he when he's at home?
  -- Ulysses

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @JohnPeacock

Rafael Garcia-Suarez wrote​:

A more general, but unclean, fix, would be to avoid deleting any GV in
%​:: that has the GvMULTI flag set. More clean, add a flag for "global
immortal" variables that should never be deleted from %​::. I don't know
where to find room for flags, though. Opinions ?

I got bitten by this a few times too (while spelunking in the core to
add an overloaded object, re​: version objects). If the problem case is
$@​/PL_errgv, can't we just refuse to delete that out of $​:: instead of
trying to make a more general solution? The only time that can safely
be nuked (AFAICT) is during final cleanup when Perl itself is shutting down.

John

--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5748

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @JohnPeacock

Rafael Garcia-Suarez wrote​:

I remember also fixing a similar problem with STDERR, or was it STDOUT.
I suspect that other problems may be lurking.

Yes, it is likely that the same problem exists with both of those as
well (although they may already be fixed). I would go so far as to
speculate that the problem cases are all ones where Perl itself is
communicating with the outside world.

I'm just suggesting that there is probably a minimum number of
"specials" which need to be protected by name, rather than trying to
forge a more generic solution. Even if you did find a flag bit to play
with (and I don't know where one might be found, cause I looked for the
v-string mess), you'd still have to identify which gv's needed protecting.

John

--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5748

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @rgs

John Peacock wrote​:

I got bitten by this a few times too (while spelunking in the core to
add an overloaded object, re​: version objects). If the problem case is
$@​/PL_errgv, can't we just refuse to delete that out of $​:: instead of
trying to make a more general solution? The only time that can safely
be nuked (AFAICT) is during final cleanup when Perl itself is shutting down.

I remember also fixing a similar problem with STDERR, or was it STDOUT.
I suspect that other problems may be lurking.

--
Q​: How many extreme programmers does it take to change a lightbulb?
A​: Two (Firstly to write the regression tests, then to declare that it's a
  hardware problem) -- Nicholas Clark in p5p

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @rgs

John Peacock wrote​:

Yes, it is likely that the same problem exists with both of those as
well (although they may already be fixed). I would go so far as to
speculate that the problem cases are all ones where Perl itself is
communicating with the outside world.

I'm just suggesting that there is probably a minimum number of
"specials" which need to be protected by name, rather than trying to
forge a more generic solution. Even if you did find a flag bit to play
with (and I don't know where one might be found, cause I looked for the
v-string mess), you'd still have to identify which gv's needed protecting.

That's why I was suggesting to use GvMULTI for this purpose : globals
vars that are not used only once, i.e. real built-in globals and
imported variables. Although deleting imported variables from %​:: might
be justifiable. Maybe :)

--
Grepping the source is good for the soul. -- the perldebguts manpage

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @JohnPeacock

Rafael Garcia-Suarez wrote​:

That's why I was suggesting to use GvMULTI for this purpose : globals
vars that are not used only once, i.e. real built-in globals and
imported variables. Although deleting imported variables from %​:: might
be justifiable. Maybe :)

I don't know, I think it's pretty daft to nuke $​:: like that in the
first place. It might be justifiable to just forbid the mass deletion
itself and force anyone who wants to, to walk the hash and delete the
keys manually. Is that harder to code?

Anyone want to give an actual use-case for clearing the $​:: in the first
place???

John

--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5748

@p5pRT
Copy link
Author

p5pRT commented Dec 14, 2004

From @rgs

John Peacock wrote​:

I don't know, I think it's pretty daft to nuke $​:: like that in the
first place. It might be justifiable to just forbid the mass deletion
itself and force anyone who wants to, to walk the hash and delete the
keys manually. Is that harder to code?

Won't help :

$ perl -e 'eval{delete$​::{q{@​}}}'
Segmentation fault

Anyone want to give an actual use-case for clearing the $​:: in the first
place???

Clean up the namespace when you've imported lots of symbols ? If you happen
to re-load things afterwards ?

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

From @iabyn

On Tue, Dec 14, 2004 at 12​:12​:12PM -0500, John Peacock wrote​:

I don't know, I think it's pretty daft to nuke $​:: like that in the
first place. It might be justifiable to just forbid the mass deletion
itself and force anyone who wants to, to walk the hash and delete the
keys manually. Is that harder to code?

I submitted a patch a year or two back to forbid packagemainicide, but
it was rejected, presumably on the grounds that it was too much of a
special case. There again, %​:: deletion bugs seem to crop up with tedious
regularity. IIRC correctly, my patch stopped the obvious cases of
deletion, but wouldn't stop pathological cases (ie if you *really* tried
you could still do it).

Dave.

--
"Strange women lying in ponds distributing swords is no basis for a system
of government. Supreme executive power derives from a mandate from the
masses, not from some farcical aquatic ceremony."
  -- Dennis - Monty Python and the Holy Grail.

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2004

From @hvds

Rafael Garcia-Suarez <rgarciasuarez@​mandrakesoft.com> wrote​:
:And likewise
:
: $ perl -e 'eval{%​::=()}'
: Segmentation fault
:
:There is a whole class of problems that come from this.
:In this case, it's $@​ (or, internally, PL_errgv) being accessed _after_
:it has been deleted.
:
:A more general, but unclean, fix, would be to avoid deleting any GV in
:%​:: that has the GvMULTI flag set. More clean, add a flag for "global
:immortal" variables that should never be deleted from %​::. I don't know
:where to find room for flags, though. Opinions ?

I wonder whether an alternative route to fixing is to allow the deletion,
but cope with it by ensuring that variables that need to exist are
revivified when required.

I've no idea though how easy that would be to do, nor whether blindly
assuming they'll exist saves enough time to warrant putting checks
elsewhere to ensure the assumption remains valid.

Hugo

@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2004

From @nwc10

On Wed, Dec 15, 2004 at 02​:51​:55PM +0000, hv@​crypt.org wrote​:

I wonder whether an alternative route to fixing is to allow the deletion,
but cope with it by ensuring that variables that need to exist are
revivified when required.

I've no idea though how easy that would be to do, nor whether blindly
assuming they'll exist saves enough time to warrant putting checks
elsewhere to ensure the assumption remains valid.

Or by moving out the code that creates them into a separate function,
still called from the regular setup, but arranging for it also to be called
as a special case just after %​:: is deleted.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2005

From @davidnicol

perl -e ' CHECK{local *​::; %​::=()}'

doesn't crash. Maybe a better solution is to localize *​:: and let it fall
out of scope, instead of trying to clear it? Although writing around this
would undeniably be a headache.
 

--
David L Nicol
You're striving for harmony, and, if you try to take
too much, you'll come to grief. -- Michael Redmond

@p5pRT
Copy link
Author

p5pRT commented Jun 7, 2005

From @smpeters

[gt4556a@​prism.gatech.edu - Tue Jun 19 09​:30​:12 2001]​:

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

undef()ing the symbol table of package main causes coredumps. The
problem has
been reproduced on at least two version of Perl (5.00505 and 5.6.1,
both on
SunOS) and two people (on different machines).

Test program​:

sub aaa {};
undef %​::;

Note that the coredump doesn't occur for certain names of the above
sub.
Examples​:

* a
* aa
* b
* [try letters in between?]
* z
* za - zh

There are certainly more names. That don't trigger the coredump.
Defining a
variable instead of a sub before undef()ing %​:: gives no coredump
either.

As of 5.6.2, this does still core dump; however, as of at least 5.8.6,
this does not core dump, so this ticket is resolved.

@p5pRT
Copy link
Author

p5pRT commented Nov 8, 2005

From @smpeters

[alanbur@​mower.uk.sun.com - Sun Feb 18 19​:24​:39 2001]​:

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

If you delete a stash and then try to call something it it you get a
SEGV.
Hardly surprising I suppose, but perhaps something should be done
about it
sometime.

$ perl -e 'sub bang { print "bang!\n"; } undef %main​::; bang;'
Segmentation Fault(coredump)

$ pstack core
core 'core' of 103834​: /usr/local/bin/perl -e sub bang { print
"bang!\n"; } undef %main​::; bang;'
ff27ca34 Perl_hv_fetch (2e9a0, ffbee6f0, b, 0, a2411bd1, 2d948) + 16c
ff229874 Perl_gv_fetchpv (b, 0, 3a, 0, 2d348, ff30ac24) + 160
ff229430 Perl_gv_stashpvn (ff2f37e8, ffbee850, 0, ff2f37e8, 9,
3a535550) + 60
ff228d6c Perl_gv_fetchmeth (a, 36174, 7, 0, ff30ac24, 3606c) + 4ac
ff229054 Perl_gv_fetchmethod_autoload (3606c, 3606c, 7, ff30ac24,
ff2f86f8, 1) + 160
ff295660 Perl_sv_clear (2faf4, 1000, 34770, ff0b6000, 22994,
ff0419f8) + b4
ff296010 Perl_sv_free (360e4, ff30ac24, 0, 1c, 2296c, ff276190) + 1c0
ff22b220 Perl_gp_free (36a08, 360f0, d, 600d, 22994, ff0419f8) + 130
ff295bc8 Perl_sv_clear (0, 1000, c, 0, 2296c, ff27ef34) + 61c
ff296010 Perl_sv_free (360f0, ff30ac24, 360f0, ff30ac24, 2e968,
32f2c) + 1c0
ff27e5b0 Perl_hv_free_ent (2d948, 34080, ff3a0414, 0, ff3e2698,
ff20e503) + 94
ff27e7ec S_hfreeentries (1f, 363c8, 7c, 1f, 33db0, 2d948) + 4c
ff27e840 Perl_hv_undef (2e9a0, 2d948, 2000000b, 0, 0, 0) + 14
ff29efb8 Perl_pp_undef (2d49c, 2d4a0, ff30ac24, 2faf4, 2d948, 2faf4)
+ 13c
ff2822d8 Perl_runops_standard (ff30ac24, 2d49c, ffbeeecc, 0,
ff3e2698, 11572) + 44
ff222940 S_run_body (1, ff31b494, ff30ac24, ff317090, ff30ac24,
ff31b648) + 1dc
ff222564 perl_run (2d4d0, 11b94, 3, ffbeefec, 0, 3) + 2a0
00011b44 main (0, 2d330, 2cd08, ffbeefec, 0, 0) + 9c
00011a80 _start (0, 0, 0, 0, 0, 0) + b8

This has been fixed with change #26043.

./perl -e 'sub bang { print "bang!\n"; } undef %main​::; bang;'
bang!

@p5pRT
Copy link
Author

p5pRT commented Nov 8, 2005

@smpeters - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Nov 8, 2005
@p5pRT
Copy link
Author

p5pRT commented Mar 3, 2006

From jeff@zeroclue.com

At least with perl 5.8.6 on Mac OS X Tiger, this appers to still be a
problem​:

[goo​:~/Data Files] jeff% perl -e 'END{ %​::=() }'
Bus error
[goo​:~/Data Files] jeff% perl -v

This is perl, v5.8.6 built for darwin-thread-multi-2level

1 similar comment
@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2006

From jeff@zeroclue.com

At least with perl 5.8.6 on Mac OS X Tiger, this appers to still be a
problem​:

[goo​:~/Data Files] jeff% perl -e 'END{ %​::=() }'
Bus error
[goo​:~/Data Files] jeff% perl -v

This is perl, v5.8.6 built for darwin-thread-multi-2level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant