Mailing List Archive

Horrid warnings and coredumps when being cruel to GLOBS
perl5.001n (and m), i486-novell-sysv4.2 (UnixWare 1.2)

The following brain dead code, loosely inspired by all the dynamicaly generated filehandles/globs stuff that's been floating around seems to make Perl sick:

sub test {
local (*{"bug"});
my $self = delete $main::{"bug"};
$self;
}

print "try 1\n";
test;
print "ok\n";
print "try 2\n";
test;
print "ok\n";

When run I get

try 1
Attempt to free unreferenced glob pointers at bug4.perl line 8.
ok
try 2
Segmentation Fault (core dumped)

The stack trace is:

Stack Trace for p1, Program perl
[6] leave_scope(0x6) [0x8008cc3a]
[5] pop_scope(presumed: 0x800b15ec, 0, 0x8047d2c) [0x8008bb8d]
[4] pp_leavesub(presumed: 0x800b15ec, 0x8004bc1a, 0x804da58) [0x80078e1c]
[3] run(presumed: 0x804da58, 0, 0x804933c) [0x80074bc1]
[2] perl_run(presumed: 0x804e404, 0x800344a0, 0x80c0f4c) [0x8004bc15]
[1] main(0x2, 0x8047d2c, 0x8047d38) [0x8049337]
[0] _start() [0x8049182]

I guess that what I'm doing is pretty cruel, but I was a bit supprised perl actualy dumped core.

By the way, changing the code to say

my $self = \delete $main::{"bug"};

(which is what I really meant in the first place) seems to fix the problem.

--
John Hughes <john@AtlanTech.COM> or <JH10@CalvaCom.FR>,
Atlantic Technologies Inc. Tel: +33-1-43204546
24 rue Montbrun, Fax: +33-1-43204579
75014 PARIS.