-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:
Apache2 segfaults when a virtual host is configured with
PerlOptions -Enable (using the libapache2-mod-perl2 package on a
stock Ubuntu 7.04 installation).
A test case using bug-reporting-skeleton-mp2.tar.gz is available at
http://www.ece.ubc.ca/~derekp/webdevel/mp2-perloptions-enable-bug.tar.gz
A patch to fix the segfault is included below. While it does fix the
segfault, it is not thoroughly tested.
2. Used Components and their Configuration:
*** mod_perl version 2.000002
*** using /usr/lib/perl5/Apache2/BuildConfig.pm
*** Makefile.PL options:
MP_APR_LIB => aprext
MP_APXS => /usr/bin/apxs2
MP_CCOPTS => -g -Wall
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_INCLUDE_DIR => /usr/include/apache2 /usr/include/apr-1.0
MP_LIBNAME => mod_perl
MP_TRACE => 0
MP_USE_DSO => 1
MP_USE_GTOP => 1
MP_USE_STATIC => 0
*** /usr/sbin/apache2 -V
Server version: Apache/2.2.3
Server built: Jan 15 2007 18:14:50
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
*** /usr/bin/ldd /usr/sbin/apache2
linux-gate.so.1 => (0xffffe000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7eb6000)
libpcre.so.3 => /usr/lib/libpcre.so.3 (0xb7e96000)
libaprutil-1.so.0 => /usr/lib/libaprutil-1.so.0 (0xb7e7c000)
libldap_r.so.2 => /usr/lib/libldap_r.so.2 (0xb7e46000)
liblber.so.2 => /usr/lib/liblber.so.2 (0xb7e39000)
libdb-4.4.so => /usr/lib/libdb-4.4.so (0xb7d3b000)
libpq.so.5 => /usr/lib/libpq.so.5 (0xb7d1d000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0xb7cbf000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0xb7c9f000)
libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0xb7c7c000)
libuuid.so.1 => /lib/libuuid.so.1 (0xb7c79000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7c70000)
libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb7c41000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7c2a000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7c26000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ae5000)
/lib/ld-linux.so.2 (0xb7eeb000)
libresolv.so.2 => /lib/tls/i686/cmov/libresolv.so.2 (0xb7ad2000)
libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb7aba000)
libgnutls.so.13 => /usr/lib/libgnutls.so.13 (0xb7a4a000)
libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb7a0a000)
libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8
(0xb78c8000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb784b000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0xb7847000)
libtasn1.so.3 => /usr/lib/libtasn1.so.3 (0xb7832000)
libz.so.1 => /usr/lib/libz.so.1 (0xb781e000)
libgcrypt.so.11 => /usr/lib/libgcrypt.so.11 (0xb77cd000)
libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0xb77c9000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb77a3000)
libnsl.so.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb778c000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0xb7788000)
*** (apr|apu)-config linking info
-L/usr/lib -laprutil-1
-L/usr/lib -lapr-1 -luuid -lrt -lcrypt -lpthread -ldl
*** /usr/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.15.7, archname=i486-linux-gnu-thread-multi
uname='linux rothera 2.6.15.7 #1 smp sat sep 30 10:21:42 utc 2006
i686 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr
-Dprivlib=/usr/shar
e/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr
-Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5
-Dsiteprefix=/usr/local -Ds
itelib=/usr/local/share/perl/5.8.8 -Dsitearch=/usr/local/lib/perl/5.8.8
-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1d
ir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1
-Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -U
usenm -Duseshrplib -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBIAN -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOU
RCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN
-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='4.1.2 (Ubuntu 4.1.2-0ubuntu4)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
perllibs=-ldl -lm -lpthread -lc -lcrypt
libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8
gnulibc_version='2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Mar 6 2007 01:40:14
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/etc/perl
/usr/local/lib/perl/5.8.8
/usr/local/share/perl/5.8.8
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.8
/usr/share/perl/5.8
/usr/local/lib/site_perl
.
*** Packages of interest status:
Apache2 : -
Apache2::Request : -
CGI : 3.15
ExtUtils::MakeMaker: 6.30_01
LWP : 5.805
mod_perl : -
mod_perl2 : 2.000002
3. This is the core dump trace: (if you get a core dump):
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1215895344 (LWP 1694)]
0xb78314a9 in modperl_hash_handlers_dir (p=0x80a50c8, s=0x81adda0, cfg=0x0,
d=0x81932d8 "/home/*/public_html/", data=0x0) at modperl_mgv.c:483
483 MP_dSCFG_dTHX;
(gdb) bt
#0 0xb78314a9 in modperl_hash_handlers_dir (p=0x80a50c8, s=0x81adda0,
cfg=0x0, d=0x81932d8 "/home/*/public_html/", data=0x0) at
modperl_mgv.c:483
#1 0xb78316bf in ap_pcw_walk_directory_config (pconf=0x80a50c8,
s=0x81adda0,
sconf=0x81afd10, modp=0xb78440e0,
dir_cb=0xb7831480 <modperl_hash_handlers_dir>, data=0x0)
at modperl_pcw.c:55
#2 0xb7831883 in ap_pcw_walk_config (pconf=0x80a50c8, s=0x81adda0,
modp=0xb78440e0, data=0x0, dir_cb=0xb7831480
<modperl_hash_handlers_dir>,
srv_cb=0xb7831370 <modperl_hash_handlers_srv>) at modperl_pcw.c:120
#3 0xb78306fa in modperl_mgv_hash_handlers (p=0x80a50c8, s=0x80af568)
at modperl_mgv.c:529
#4 0xb7822365 in modperl_hook_post_config_last (pconf=0x80a50c8,
plog=0x80d7190, ptemp=0x80d9198, s=0x80af568) at mod_perl.c:716
#5 0x08078f30 in ap_run_post_config ()
#6 0x08066a59 in main ()
(gdb) print *(modperl_config_srv_t
*)ap_get_module_config(s->module_config, &perl_module)
$1 = {setvars = 0x81afbe0, configvars = 0x81afac8, SetEnv = 0x81af768,
PassEnv = 0x81af880, PerlRequire = 0x81aec68, PerlModule = 0x81aec48,
PerlPostConfigRequire = 0x81aec88, handlers_per_srv = {0x0, 0x0, 0x0},
handlers_files = {0x0, 0x0}, handlers_process = {0x0, 0x0},
handlers_pre_connection = {0x0}, handlers_connection = {0x0}, mip = 0x0,
interp_pool_cfg = 0x81af188, interp_scope = MP_INTERP_SCOPE_REQUEST,
argv = 0x81aeca8, flags = 0x81afcf8, modules = 0x0, server = 0x81adda0}
This report was generated by /usr/bin/mp2bug on Sat Jun 30 08:54:49 2007
GMT.
-------------8<---------- End Bug Report --------------8<----------
--- src/modules/perl/modperl_cmd.c.enable 2005-10-20
17:04:26.000000000 -0700
+++ src/modules/perl/modperl_cmd.c 2007-06-30 02:17:48.000000000 -0700
@@ -174,7 +174,7 @@
return "init mod_perl vhost failed";
}
- if (modperl_is_running()) {
+ if (modperl_vhost_is_running(parms->server)) {
char *error = NULL;
MP_TRACE_d(MP_FUNC, "load PerlModule %s\n", arg);
@@ -212,7 +212,7 @@
return "init mod_perl vhost failed";
}
- if (modperl_is_running()) {
+ if (modperl_vhost_is_running(parms->server)) {
char *error = NULL;
MP_TRACE_d(MP_FUNC, "load PerlRequire %s\n", arg);
@@ -496,6 +496,11 @@
const char *pkg_name = NULL;
ap_directive_t *directive = parms->directive;
MP_dSCFG(s);
+ if (!MpSrvENABLE(scfg)) {
+ return apr_pstrcat(parms->pool,
+ "Perl is disabled for server ",
+ s->server_hostname, NULL);
+ }
MP_PERL_CONTEXT_DECLARE;
if (!(arg && *arg)) {
--- src/modules/perl/modperl_interp.c.enable 2005-10-20
17:04:26.000000000 -0700
+++ src/modules/perl/modperl_interp.c 2007-06-30 02:17:48.000000000 -0700
@@ -550,11 +550,17 @@
modperl_interp_mip_walk(current_perl, base_perl,
base_scfg->mip, walker, data);
- while (s) {
+ for (; s; s = s->next) {
MP_dSCFG(s);
- PerlInterpreter *perl = scfg->mip->parent->perl;
modperl_interp_pool_t *mip = scfg->mip;
+ /* skip vhosts with mod_perl disabled */
+ if (!mip) {
+ continue;
+ }
+
+ PerlInterpreter *perl = mip->parent->perl;
+
/* skip vhosts who share parent perl */
if (perl == base_perl) {
perl = NULL;
@@ -569,8 +575,6 @@
modperl_interp_mip_walk(current_perl, perl,
mip, walker, data);
}
-
- s = s->next;
}
}
--- src/modules/perl/modperl_pcw.c.enable 2005-10-20
17:04:26.000000000 -0700
+++ src/modules/perl/modperl_pcw.c 2007-06-30 02:17:48.000000000 -0700
@@ -107,6 +107,13 @@
ap_pcw_dir_cb_t dir_cb, ap_pcw_srv_cb_t srv_cb)
{
for (; s; s = s->next) {
+#ifdef USE_ITHREADS
+ MP_dSCFG(s);
+ if (!scfg->mip) {
+ /* mod_perl disabled for this virtual host */
+ continue;
+ }
+#endif
core_dir_config *dconf =
ap_get_module_config(s->lookup_defaults,
&core_module);