perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@ectoplasm.org>
Subject Re: [mp2] <Perl> block & PerlOptions +Parent & PerlRequire segfaults on 2.0.2, but not 2.0.1
Date Sat, 21 Jan 2006 01:53:46 GMT
Eamon Daly wrote:
> 1. Problem Description:
> 
> If I declare a <Perl> section in httpd.conf, then define
> a virtual host with "PerlOptions +Parent", httpd dies with
> a segfault on subsequent PerlRequires. This works in 2.0.1.
> Here's a minimal example, tacked on to the end of the
> default httpd.conf:
> 
> --- httpd.conf ---
> 
> <Perl>
> 1;
> </Perl>
> 
> <VirtualHost _default_:80>
>    ServerAdmin webmaster@dummy-host.example.com
>    DocumentRoot /www/docs/dummy-host.example.com
>    ServerName dummy-host.example.com
>    ErrorLog logs/dummy-host.example.com-error_log
>    CustomLog logs/dummy-host.example.com-access_log common
>    PerlOptions +Parent
>    PerlRequire /etc/httpd/conf/startup.pl
> </VirtualHost>
> 
> --- startup.pl ---
> 
> use strict;
> 
> 1;
> 
> Is this just bad syntax on our part that luckily Just
> Worked or is this broken behavior in 2.0.2?

This is certainly a bug and was, if not introduced, aggravated by this change
of mine [291193].

It exposed a bug in the implementation of "PerlSwitches +inherit" [1], which led
me to realize that it was broken. This bit of code is seriously wrong:

in src/modules/perl/modperl_cmd.c:
  if (add->argv->nelts == 2 && strEQ(((char **)add->argv->elts)[1], "+inherit"))
{

That's making quite a few incorrect assumptions. Like that the '+inherit' option
would always be the second one, and only recognized if it was the second one.

On top of that, specifying

PerlSwitches +inherit

in your httpd.conf, it would end up in the argv that's passed to perl_parse(), so you'd
end up with this lovely startup error:

Can't open perl script "+inherit": No such file or directory
perl_parse: No such file or directory

After some initial tinkering, I think the following patch is a much better solution.
I've made the switch inheriting option a proper per-server config, and I skip adding
it to perl's argv[].

Let me know if this solves your problem.

1      - http://perl.apache.org/docs/2.0/user/config/config.html#C_Clone_
291193 - (http://svn.apache.org/viewcvs.cgi?rev=291193&view=rev)

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Mime
View raw message