Title: RE: :Parse segmentation fault
This allows for XML parsing with no change to the Perl code.  I'm just not sure what I am losing in Apache (which is where I make the change).  What does losing EXPAT do to Apache?
-----Original Message-----
From: Shane Adams [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 4:02 PM
To: Herrington, Jack; '[EMAIL PROTECTED]'
Subject: RE: :Parse segmentation fault

Hmmm well I *have* to have Xml parsing. Not sure if what you are suggesting totally turns it off or just does something else?
-----Original Message-----
From: Herrington, Jack [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 3:49 PM
To: Shane Adams; '[EMAIL PROTECTED]'
Subject: RE: :Parse segmentation fault

I did a little more digging around and found that you could also avoid the problem by turning off EXPAT in apache with:
 
Rule EXPAT=no
 
Which fix is more preferable?
-----Original Message-----
From: Shane Adams [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 3:43 PM
To: Herrington, Jack; '[EMAIL PROTECTED]'
Subject: RE: :Parse segmentation fault

Yes.  We found a problem in Expat.pm line 451 (in sub parse).  The following chunk of code (latest version from cpan)

sub parse {
  my $self = shift;
  my $arg = shift;
  croak "Parse already in progress (Expat)" if $self->{_State_};
  $self->{_State_} = 1;
  my $parser = $self->{Parser};
  my $ioref;
  my $result = 0;

  if (defined $arg) {
    if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handler')) {
      $ioref = $arg;
    } else {
      eval {
        $ioref = *{$arg}{IO};   ### Problem code
      };
      undef $@;
    }
  }
## Rest snipped

As you can see it's trying to oddly reference what you passs in to parse as some screwed up typeglof reference.  In your example (and indeed in our code) we where simply passing a scalar.  This generated coredumps.  We got around the problem by just commenting out the eval and $ioref code, So The above became

    if (ref($arg) and UNIVERSAL::isa($arg, 'IO::Handler')) {
      $ioref = $arg;
    } else {
      ##eval {
      ##  $ioref = *{$arg}{IO};   ### Problem code
      ##};
      undef $@;
    }

Clean fix?  No, but we are always dealing with scalars, not some other sort of odd input stream and just punted on the problem.  Core dumps disappeared. 



-----Original Message-----
From: Herrington, Jack [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2000 3:03 PM
To: '[EMAIL PROTECTED]'
Subject: XML::Parse segmentation fault


This code works as a perl script executed off the command line:

        use XML::Parser;
        my $parser = new XML::Parser();
        $parser->parse( "<form></form>" );

This code fails with a segmentation fault when called from mod_perl:

        package CBL::mod_perl::test1;

        use strict;
        use XML::Parser;

        sub handler
        {
                my $r = shift;

                my $parser = new XML::Parser();
                $parser->parse( "<form></form>" );

                $r->content_type( 'text/html' );
                $r->send_http_header;
                $r->print( "<html><body>" );
                $r->print( "Testing" );
                $r->print( "</body></html>" );

                return OK;
        }

        1;

Is there some inherint problem with XML::Parser and mod_perl?

Jack Herrington
        Engineering Manager
        Certive - Building the world's first broadband B2B network
        (650) 701-8809

Reply via email to