in reply to Bug ? Perl dumps core on reference to @_ ?

As somebody who dosen't poke around in perls internals, my wild guess is that @_ in the "pre"-callback contains a (pointer to a) glob whose object has passed out of existence already, but that's a wild guess obviously.

In a "pre" callback, the last argument is really a reference to a Hook::LexWrap::Cleanup object (a blessed subroutine), which masquerades as undef when used as an rvalue.

When $_[-1] is assigned to in a "pre" callback, this object loses its last reference, so its destructor is called, which invokes the advertised "short-circuiting" of the wrapped subroutine.

Not having (or wanting!) access to a Windows machine, I can only guess that something in LexWrap is tripping a bug in the IndigoPerl core -- possibly something to do with destructor timing. :-(

Replies are listed 'Best First'.
Re: Re: Bug ? Perl dumps core on reference to @_ ? (Stringify bug ??)
by Corion (Patriarch) on Dec 02, 2001 at 08:22 UTC

    Your idea of wrong destructor timing made me take a second and deeper look at Hook::LexWrap (and some inserted print statements), and I could produce another core dumping script, which should trigger the same error as Hook::LexWrap with IndigoPerl :

    #!/usr/bin/perl -w use strict; use warnings; my @a = (); my $foo = bless \@a, 'Cleanup'; print $foo; package Cleanup; use overload q{""} => sub { undef }, #q{""} => sub { "foo" }, q{0+} => sub { undef }, q{bool} => sub { undef }; 1;

    It now seems to me as if the stringifying dosen't work correctly, because everything works fine if the second variant of stringifying (returning foo) is enabled. Destructors don't come into play, as I'm not defining any destructor anymore, it seems more like it's a stringify problem with classes that stringify to undef...

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web