On Wed, Jun 28, 2000 at 10:46:29AM +0200, Gisle Aas screived:
>
> > sub text {
> > my ($self, $text) = @_;
> >
> > print STDERR "$text\n----- END CHUNK -----\n";
> > @_ = split(/\W/, $text); ## this causes the segfault
> > }
>
> By the assignment to @_ you are clobbering $self and other stuff. Why
> don't you use your own lexical array??? :-)
Sorry, I culled that program from something bigger and only used @_ on the
spur of the moment, to stop -w giving a warning about a useless split!
It was my belief at the time that it was the split command itself that
was causing the segmentation fault [now known to be untrue].
(Ironically, it turns out that -w doesn't give a warning when split
is the last command in a method anyway, as it is then the return value!)
> ...but HTML::Parser was stupid enough to send the same reference to
> all calls. That meant that the next handler invoked got your
> clobbered $self as its argument and eventually perl got confused
> during global destruction. This patch make sure that we copy the
> reference for each callback invocation. That should cure the problem.
I think I understand... however, this is apparently *not* the cause of
the problem. I have applied the patch, and the segmentation fault still
occurs at the @_ assignment!
Furthermore, a segmentation fault even occurs for assignment to a lexical!
e.g.
sub text {
my ($self, $text) = @_;
print STDERR "$text\n----- END CHUNK -----\n";
my @blahblah = split(/\W/, $text); ## this causes the segfault
}
And... if you reverse the order of the print and assignment lines, then
you get a `bus error' instead of a segmentation fault! Very, very strange...
cheers,
ian
--
+-------------------------------------+---------------------------------------+
| ian miller; research student; | [EMAIL PROTECTED] |
| university of aberdeen, scotland. | http://www.csd.abdn.ac.uk/~imiller/ |
+-------------------------------------+---------------------------------------+