FAQ
-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:


Summary
============

Calling "local %ENV" from anywhere inside a mod_perl handler will
terminally
flaw the httpd process. The httpd process will function fine on the first
request, but will die the next time it is asked to handle a request.

Apache error.log or error_log will contain one of the following.

[notice] child pid <PID> exit signal Segmentation fault (11)
[notice] child pid <PID> exit signal Bus error (10)

Calling local %ENV seems fine on:
mod_perl 1.99_09

Calling local %ENV creates a terminal flaw on:
mod_perl 1.99_16
mod_perl 1.999_21
mod_perl 2.0.2

I spotted this because I was using Sys::HostIP, which has been calling
local %ENV inside _get_unix_interface_info since version 1.1 (07 Apr
2002).
http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.1/HostIP.pm
http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.3.1/HostIP.pm

Some example test files are given below.


Testing Performed On
=========================
Main tests on:
Fedora Core 3
Mac OS X 10.3.9

Results were consistent with other installs on:
Red Hat 9
Fedora Core 2 (FC2)
Fedora Core 4 (FC4)
Red Hat Enterprise Linux 3 (RHEL3)
Mac OS X 10.4.3
Windows Server 2000
Windows Server 2003
Windows XP Pro



Configuring httpd.conf
===========================

For ease of testing reduce the number of forked httpd processes in
httpd.conf:

<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 1
MaxClients 150
MaxRequestsPerChild 0
</IfModule>




Fedora Core 3
==================

First tried with the RPMs FC3 came with:
httpd-2.0.52-3.i386.rpm
mod_perl-1.99_16-3.rpm


Then upgraded to latest mod_perl and Apache to see if the problem had
been fixed (which it hadn't).
mod_perl 2.0.2 (VERSION 2.000002)
Apache 2.0.53
Perl 5.8.5

The process dies with:
[notice] child pid <PID> exit signal Segmentation fault (11)



FILE: Mod_Perl_ENV_Bug_Test.conf

LoadModule perl_module modules/mod_perl.so

Listen 80

<VirtualHost *:80>
PerlOptions +Parent
PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
PerlModule Bundle::Apache2
PerlModule MyHandler
<LocationMatch ^/+$>
SetHandler perl-script
PerlResponseHandler MyHandler
</LocationMatch>
</VirtualHost>



FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm

package MyHandler;

use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const ('-compile',('OK'));
use Sys::HostIP;

sub handler($) {
my $r = shift();
# The error is produced by either of the following two lines
local %ENV;
#Sys::HostIP->ips();
$r->content_type('text/html');
print('Testing');
return Apache2::Const::OK;
}

1;




Mac OS X 10.3.9
====================

mod_perl was compiled from source.

Darwin Kernel Version 7.9.0
mod_perl 2.0.0-RC4 (VERSION 1.999021)
Apache 2.0.52
Perl 5.8.1-RC3

The process dies with:
[notice] child pid <PID> exit signal Bus error (10)



FILE: Mod_Perl_ENV_Bug_Test.conf

LoadModule perl_module modules/mod_perl.so

Listen 80

<VirtualHost *:80>
PerlOptions +Parent
PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
PerlModule Apache2
PerlModule MyHandler
<LocationMatch ^/+$>
SetHandler perl-script
PerlResponseHandler MyHandler
</LocationMatch>
</VirtualHost>



FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm

package MyHandler;

use strict;
use warnings;
use Apache::RequestRec ();
use Apache::Const -compile=>qw(OK);
use Sys::HostIP;

sub handler($) {
my $r = shift();
# The error is produced by either of the following two lines
local %ENV;
#Sys::HostIP->ips();
$r->content_type('text/html');
print('Testing');
return Apache::OK;
}

1;


===============================
OpenAsset - Image Management for Architects, Designers & Engineers
Axomic Ltd
338 City Road
London EC1V 2PY
t: +44 (0)20 7239 8287
m: +44 (0)7812 122418
http://www.axomic.com






2. Used Components and their Configuration:

*** mod_perl version 1.9916

*** using
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/Apache/BuildConfig.pm

*** Makefile.PL options:
MP_APR_CONFIG => /usr/bin/apr-config
MP_APR_LIB => aprext
MP_APXS => /usr/sbin/apxs
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1
MP_USE_STATIC => 1


*** The httpd binary was not found


*** (apr|apu)-config linking info

-lapr-0 -lrt -lm -lcrypt -lpthread -ldl
-laprutil-0 -lldap -llber -ldb-4.2 -lexpat



*** /usr/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
Platform:
osname=linux, osvers=2.4.21-14.elsmp, archname=i386-linux-thread-multi
uname='linux tweety.build.redhat.com 2.4.21-14.elsmp #1 smp wed apr 14
18:55:47 edt 2004 i686 i686 i386 gnulinux '
config_args='-des -Doptimize=-O2 -g -pipe -m32 -march=i386
-mtune=pentium4 -Dversion=5.8.5 -Dmyhostname=localhost
-Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc.
-Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm
-Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
-Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
-isr -Dinc_version_list=5.8.4 5.8.3 5.8.2 5.8.1 5.8.0'
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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O2 -g -pipe -m32 -march=i386 -mtune=pentium4',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING
-fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='3.4.2 20041006 (Red Hat 3.4.2-5)',
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='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.3.3.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.3'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Built under linux
Compiled at Oct 12 2004 12:45:01
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
/usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5
/usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3
/usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5
/usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3
/usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
.

*** Packages of interest status:

Apache::Request: -
CGI : 3.05
LWP : 5.79
mod_perl : 1.9916


3. This is the core dump trace: (if you get a core dump):

[CORE TRACE COMES HERE]

This report was generated by /usr/bin/mp2bug on Mon Dec 12 17:16:51 2005
GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
modperl <at> perl.apache.org. To subscribe to the list send an empty
email to modperl-subscribe@perl.apache.org.

Search Discussions

  • Peter Walsham at Dec 14, 2005 at 4:58 am
    -------------8<---------- Start Bug Report ------------8<----------
    1. Problem Description:



    Summary
    ============

    Calling "local %ENV" from anywhere inside a mod_perl handler will
    terminally
    flaw the httpd process. The httpd process will function fine on the first
    request, but will die the next time it is asked to handle a request.

    Apache error.log or error_log will contain one of the following.

    [notice] child pid <PID> exit signal Segmentation fault (11)
    [notice] child pid <PID> exit signal Bus error (10)

    Calling local %ENV seems fine on:
    mod_perl 1.99_09

    Calling local %ENV creates a terminal flaw on:
    mod_perl 1.99_16
    mod_perl 1.999_21
    mod_perl 2.0.2

    I spotted this because I was using Sys::HostIP, which has been calling
    local %ENV inside _get_unix_interface_info since version 1.1 (07 Apr
    2002).
    http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.1/HostIP.pm
    http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.3.1/HostIP.pm

    Some example test files are given below.


    Testing Performed On
    =========================
    Main tests on:
    Fedora Core 3
    Mac OS X 10.3.9

    Results were consistent with other installs on:
    Red Hat 9
    Fedora Core 2 (FC2)
    Fedora Core 4 (FC4)
    Red Hat Enterprise Linux 3 (RHEL3)
    Mac OS X 10.4.3
    Windows Server 2000
    Windows Server 2003
    Windows XP Pro



    Configuring httpd.conf
    ===========================

    For ease of testing reduce the number of forked httpd processes in
    httpd.conf:

    <IfModule prefork.c>
    StartServers 1
    MinSpareServers 1
    MaxSpareServers 1
    MaxClients 150
    MaxRequestsPerChild 0
    </IfModule>




    Fedora Core 3
    ==================

    First tried with the RPMs FC3 came with:
    httpd-2.0.52-3.i386.rpm
    mod_perl-1.99_16-3.rpm


    Then upgraded to latest mod_perl and Apache to see if the problem had
    been fixed (which it hadn't).
    mod_perl 2.0.2 (VERSION 2.000002)
    Apache 2.0.53
    Perl 5.8.5

    The process dies with:
    [notice] child pid <PID> exit signal Segmentation fault (11)



    FILE: Mod_Perl_ENV_Bug_Test.conf

    LoadModule perl_module modules/mod_perl.so

    Listen 80

    <VirtualHost *:80>
    PerlOptions +Parent
    PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
    PerlModule Bundle::Apache2
    PerlModule MyHandler
    <LocationMatch ^/+$>
    SetHandler perl-script
    PerlResponseHandler MyHandler
    </LocationMatch>
    </VirtualHost>



    FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm

    package MyHandler;

    use strict;
    use warnings;
    use Apache2::RequestRec ();
    use Apache2::Const ('-compile',('OK'));
    use Sys::HostIP;

    sub handler($) {
    my $r = shift();
    # The error is produced by either of the following two lines
    local %ENV;
    #Sys::HostIP->ips();
    $r->content_type('text/html');
    print('Testing');
    return Apache2::Const::OK;
    }

    1;




    Mac OS X 10.3.9
    ====================

    mod_perl was compiled from source.

    Darwin Kernel Version 7.9.0
    mod_perl 2.0.0-RC4 (VERSION 1.999021)
    Apache 2.0.52
    Perl 5.8.1-RC3

    The process dies with:
    [notice] child pid <PID> exit signal Bus error (10)



    FILE: Mod_Perl_ENV_Bug_Test.conf

    LoadModule perl_module modules/mod_perl.so

    Listen 80

    <VirtualHost *:80>
    PerlOptions +Parent
    PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
    PerlModule Apache2
    PerlModule MyHandler
    <LocationMatch ^/+$>
    SetHandler perl-script
    PerlResponseHandler MyHandler
    </LocationMatch>
    </VirtualHost>



    FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm

    package MyHandler;

    use strict;
    use warnings;
    use Apache::RequestRec ();
    use Apache::Const -compile=>qw(OK);
    use Sys::HostIP;

    sub handler($) {
    my $r = shift();
    # The error is produced by either of the following two lines
    local %ENV;
    #Sys::HostIP->ips();
    $r->content_type('text/html');
    print('Testing');
    return Apache::OK;
    }

    1;



    2. Used Components and their Configuration:

    *** mod_perl version 1.9916

    *** using
    /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/Apache/BuildConfig.pm

    *** Makefile.PL options:
    MP_APR_CONFIG => /usr/bin/apr-config
    MP_APR_LIB => aprext
    MP_APXS => /usr/sbin/apxs
    MP_COMPAT_1X => 1
    MP_GENERATE_XS => 1
    MP_LIBNAME => mod_perl
    MP_USE_DSO => 1
    MP_USE_STATIC => 1


    *** The httpd binary was not found


    *** (apr|apu)-config linking info

    -lapr-0 -lrt -lm -lcrypt -lpthread -ldl
    -laprutil-0 -lldap -llber -ldb-4.2 -lexpat



    *** /usr/bin/perl -V
    Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
    Platform:
    osname=linux, osvers=2.4.21-14.elsmp, archname=i386-linux-thread-multi
    uname='linux tweety.build.redhat.com 2.4.21-14.elsmp #1 smp wed apr 14
    18:55:47 edt 2004 i686 i686 i386 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -m32 -march=i386
    -mtune=pentium4 -Dversion=5.8.5 -Dmyhostname=localhost
    -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc.
    -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
    -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads
    -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm
    -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
    -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
    -isr -Dinc_version_list=5.8.4 5.8.3 5.8.2 5.8.1 5.8.0'
    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='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
    -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include
    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -m32 -march=i386 -mtune=pentium4',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING
    -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='3.4.2 20041006 (Red Hat 3.4.2-5)',
    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='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.3.3.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.3.3'
    Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
    -Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'


    Characteristics of this binary (from libperl):
    Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
    USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
    Built under linux
    Compiled at Oct 12 2004 12:45:01
    %ENV:
    PERL_LWP_USE_HTTP_10="1"
    @INC:
    /usr/lib/perl5/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/5.8.5
    /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl/5.8.4
    /usr/lib/perl5/site_perl/5.8.3
    /usr/lib/perl5/site_perl/5.8.2
    /usr/lib/perl5/site_perl/5.8.1
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl/5.8.4
    /usr/lib/perl5/vendor_perl/5.8.3
    /usr/lib/perl5/vendor_perl/5.8.2
    /usr/lib/perl5/vendor_perl/5.8.1
    /usr/lib/perl5/vendor_perl/5.8.0
    /usr/lib/perl5/vendor_perl
    .

    *** Packages of interest status:

    Apache::Request: -
    CGI : 3.05
    LWP : 5.79
    mod_perl : 1.9916


    3. This is the core dump trace: (if you get a core dump):

    [CORE TRACE COMES HERE]

    This report was generated by /usr/bin/mp2bug on Mon Dec 12 17:16:51 2005
    GMT.

    -------------8<---------- End Bug Report --------------8<----------

    Note: Complete the rest of the details and post this bug report to
    modperl <at> perl.apache.org. To subscribe to the list send an empty
    email to modperl-subscribe@perl.apache.org.



    --
    Axomic Ltd
    338 City Road
    London EC1V 2PY
    t: +44 (0)20 7239 8287
    m: +44 (0)7812 122418
    http://www.axomic.com


    The information contained in this message is confidential and should not
    be disclosed to any third party whether or not you are the intended
    addressee indicated in the message. Any views or opinions presented are
    solely those of the author and do not necessarily represent those of
    Axomic Ltd. If you are not the intended recipient, be advised that you
    have received this email in error and that any use, dissemination,
    printing, forwarding or copying of this e mail is strictly prohibited.
  • Philip M. Gollucci at Dec 14, 2005 at 5:44 am
    This works for me I can even do both local and Sys::HostIP at once ! :)
    p.s. its called hostip now

    PERL: 5.8.7
    HTTPD: SVN - 2.3.0-dev prefork
    MP: SVN - 2.0.3-dev this is 2.0.2 + 2 unrelated changes
    Sys::HostIP: 1.0
    OS: FreeBSD 6.0-RELEASE

    <Location /env>
    SetHandler modperl
    PerlResponseHandler TEST::ENV
    </Location>

    package TEST::ENV;

    use strict;
    use warnings FATAL => 'all';
    use Carp;

    use Sys::HostIP;

    use Apache2::RequestRec ();
    use Apache2::Const -compile => qw(OK);

    sub handler {

    my $r = shift;

    $r->content_type('text/html');

    local %ENV;

    $r->print("IP: " . hostip);

    return Apache2::Const::OK;
    }

    1;

    GET http://localhost:8099/env
    IP: 127.0.0.1
    GET http://localhost:8099/env
    IP: 127.0.0.1

    ------------------------------------------------------------------------
    "Love is not the one you can picture yourself marrying,
    but the one you can't picture the rest of your life without."

    "It takes a minute to have a crush on someone, an hour to like someone,
    and a day to love someone, but it takes a lifetime to forget someone..."

    Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
    Consultant / http://p6m7g8.net/Resume/resume.shtml
    Senior Software Engineer - TicketMaster - http://ticketmaster.com
  • Peter Walsham at Dec 14, 2005 at 10:58 am
    Phillip,

    Thanks for your reply.

    First off a bit of CPAN wierdness. With perl -MCPAN 'install Sys::HostIP'
    you get version 1.0 (07 Jun 2000), rather than the latest version (1.3.1
    29 Sep 2003), something to do with the change of owner (five->bluelines).
    Unfortunately 1.0 is the only version which doesn't use local %ENV (...and
    hostip() was the old method not the new one).

    http://search.cpan.org/~five/Sys-HostIP-1.0 (07 Jun 2000)
    http://search.cpan.org/~bluelines/Sys-HostIP-1.3.1 (29 Sep 2003)

    Did you check how many httpd processes you had running?

    ps -A | grep httpd | wc -l

    You will only get the Seg fault or Bus error when a process comes round
    for recycling.

    For convenience you could reduce the number in httpd.conf:

    <IfModule prefork.c>
    StartServers 1
    MinSpareServers 1
    MaxSpareServers 1
    MaxClients 150
    MaxRequestsPerChild 0
    </IfModule>

    I have actively tested this problem on 6 different machines (different
    OSs and mod_per versions), and am therefore fairly sure it exists. I was
    doing some testing as I am looking to upgrade to mod_perl 2.0. I have 30+
    machines running 1.99_09 where local %ENV isn't a problem.

    Cheers Pete


    OpenAsset - Image Management for Architects, Designers & Engineers
    Axomic Ltd
    338 City Road
    London EC1V 2PY
    t: +44 (0)20 7239 8287
    m: +44 (0)7812 122418
    http://www.axomic.com


    The information contained in this message is confidential and should not
    be disclosed to any third party whether or not you are the intended
    addressee indicated in the message. Any views or opinions presented are
    solely those of the author and do not necessarily represent those of
    Axomic Ltd. If you are not the intended recipient, be advised that you
    have received this email in error and that any use, dissemination,
    printing, forwarding or copying of this e mail is strictly prohibited.
  • Philip M. Gollucci at Dec 14, 2005 at 9:50 pm

    First off a bit of CPAN wierdness. With perl -MCPAN 'install Sys::HostIP'
    you get version 1.0 (07 Jun 2000), rather than the latest version (1.3.1
    29 Sep 2003), something to do with the change of owner (five->bluelines).
    Unfortunately 1.0 is the only version which doesn't use local %ENV (...and
    hostip() was the old method not the new one).

    http://search.cpan.org/~five/Sys-HostIP-1.0 (07 Jun 2000)
    http://search.cpan.org/~bluelines/Sys-HostIP-1.3.1 (29 Sep 2003)
    I'll respond more on this in a minute as I'm lookking at it now, but
    first,
    FIVE should login on PAUSE and grant CO-MAINT to BLUELINES. The reason
    CPAN does this is its not being indexed as BLUELINES has no perms.

    i.e. The Apache-DBI debuacle recently :)
  • Philip M. Gollucci at Dec 15, 2005 at 12:39 am

    You will only get the Seg fault or Bus error when a process comes round
    for recycling.

    <IfModule prefork.c>
    StartServers 1
    MinSpareServers 1
    MaxSpareServers 1
    MaxClients 150
    MaxRequestsPerChild 0
    </IfModule>
    <Location /evn>
    SetHandler perl-script
    PerlResponseHandler TEST::ENV
    </Location>

    TEST/ENV.pm
    package TEST::ENV;

    use strict;
    use warnings FATAL => 'all';
    use Carp;

    use Sys::HostIP;

    use Apache2::RequestRec ();
    use Apache2::Const -compile => qw(OK);

    sub handler {

    my $r = shift;

    $r->content_type('text/html');

    ## core dump
    local %ENV;

    $r->print("IP: " . join ',', Sys::HostIP->ips());

    return Apache2::Const::OK;
    }

    1;


    I'll confirm that does core dump as Peter says.

    Backtrace:
    #0 0x284e4533 in modperl_env_request_tie (r=0x8ee3050) at
    modperl_env.c:404
    404 EnvMgObj = (char *)r;
    [New LWP 100139]
    (gdb) bt full
    #0 0x284e4533 in modperl_env_request_tie (r=0x8ee3050) at
    modperl_env.c:404
    No locals.
    #1 0x284d4a98 in modperl_response_handler_cgi (r=0x8ee3050) at
    mod_perl.c:1087
    dcfg = (modperl_config_dir_t *) 0x8ee1910
    h_stdin = (GV *) 0x8b6de8c
    h_stdout = (GV *) 0x8ed5950
    retval = 675975185
    rc = 135565248
    rcfg = (modperl_config_req_t *) 0x8ee3e30
    #2 0x08076f4a in ap_run_handler (r=0x8ee3050) at config.c:157
    pHook = (ap_LINK_handler_t *) 0x81679b0
    n = 9
    rv = -1
    #3 0x080776ca in ap_invoke_handler (r=0x8ee3050) at config.c:371
    handler = 0x0
    p = 0x0
    result = 0
    old_handler = 0x8148fc0 "perl-script"
    #4 0x08085238 in ap_process_request (r=0x8ee3050) at http_request.c:258
    access_status = 0
    #5 0x08082684 in ap_process_http_connection (c=0x8a75128) at
    http_core.c:171
    r = (request_rec *) 0x8ee3050
    csd = (apr_socket_t *) 0x8a75050
    #6 0x0807e58e in ap_run_process_connection (c=0x8a75128) at
    connection.c:43
    pHook = (ap_LINK_process_connection_t *) 0x8167f68
    n = 1
    rv = -1
    #7 0x0807e9cc in ap_process_connection (c=0x8a75128, csd=0x8a75050) at
    connection.c:178
    rc = -2
    #8 0x0808a53e in child_main (child_num_arg=2) at prefork.c:640
    current_conn = (conn_rec *) 0x8a75128
    csd = (void *) 0x8a75050
    ptrans = (apr_pool_t *) 0x8a75018
    allocator = (apr_allocator_t *) 0x81b5f00
    status = 0
    i = -1
    lr = (ap_listen_rec *) 0x80b6680
    pollset = (apr_pollset_t *) 0x8a733e0
    sbh = (ap_sb_handle_t *) 0x8a733d8
    bucket_alloc = (apr_bucket_alloc_t *) 0x8edd018
    last_poll_idx = 0
    #9 0x0808a6de in make_child (s=0x80b9cf8, slot=2) at prefork.c:736
    pid = 0
    #10 0x0808a93a in perform_idle_server_maintenance (p=0x80b8018) at
    prefork.c:871
    i = 0
    to_kill = -1
    idle_count = 0
    ws = (worker_score *) 0x287661e4
    free_length = 1
    free_slots = {2, 3, -1077942496, 672654516, -1077942408,
    134934528, -1077942456, 672548371, -1077942480, 0, 3, 672548298, 1, 0,
    100000
    672422316, -1077942020, 671765128, -1077942392, 672410675, 0, 0, 0, 0,
    -1077942408, 0, 1000000, 0, 134978808, 3, 1, 0}
    last_non_dead = 1
    total_non_dead = 2
    #11 0x0808adb1 in ap_mpm_run (_pconf=0x80b8018, plog=0x80e6018,
    s=0x80b9cf8) at prefork.c:1075
    status = 135221272
    pid = {pid = -1, in = 0x281459ac, out = 0xbfbfe818, err =
    0x281355da}
    child_slot = 0
    exitwhy = 672355536
    processed_status = 0
    index = 134903040
    remaining_children_to_start = 0
    rv = 0
    #12 0x080620d6 in main (argc=3, argv=0xbfbfe8ec) at main.c:712
    c = 0 '\0'
    configtestonly = 0
    confname = 0x80955ad "conf/httpd.conf"
    def_server_root = 0x80955c0
    "/usr/home/pgollucci/dev/apps/httpd/2.2.0/prefork"
    temp_error_log = 0x0
    error = 0x0
    process = (process_rec *) 0x80b6098
    server_conf = (server_rec *) 0x80b9cf8
    pglobal = (apr_pool_t *) 0x80b6018
    pconf = (apr_pool_t *) 0x80b8018
    plog = (apr_pool_t *) 0x80e6018
    ptemp = (apr_pool_t *) 0x80f5018
    pcommands = (apr_pool_t *) 0x80ba018
    opt = (apr_getopt_t *) 0x80ba0b0
    rv = 0
    mod = (module **) 0x80a0030
    optarg = 0xbfbfe884 ""
    signal_server = (apr_OFN_ap_signal_server_t *) 0x8080950
    <ap_signal_server>


    Now to see if I can fix it :)
  • Philippe M. Chiasson at Dec 16, 2005 at 1:14 am

    Philip M. Gollucci wrote:
    You will only get the Seg fault or Bus error when a process comes round
    for recycling.
    This is basically caused by the assumption that %ENV will be tied, and local %ENV
    breaks that assumption ;-S

    The following patch fixes this problem for me:

    Index: src/modules/perl/modperl_env.c
    ===================================================================
    --- src/modules/perl/modperl_env.c (revision 357090)
    +++ src/modules/perl/modperl_env.c (working copy)
    @@ -15,8 +15,11 @@

    #include "mod_perl.h"

    -#define EnvMgObj SvMAGIC((SV*)ENVHV)->mg_ptr
    -#define EnvMgLen SvMAGIC((SV*)ENVHV)->mg_len
    +#define EnvMgOK ((SV*)ENVHV && SvMAGIC((SV*)ENVHV))
    +#define EnvMgObj (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_ptr : NULL)
    +#define EnvMgLen (EnvMgOK ? SvMAGIC((SV*)ENVHV)->mg_len : 0)
    +#define EnvMgObjSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_ptr = val; }
    +#define EnvMgLenSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_len = val; }

    /* XXX: move to utils? */
    static unsigned long modperl_interp_address(pTHX)
    @@ -401,8 +404,8 @@

    void modperl_env_request_tie(pTHX_ request_rec *r)
    {
    - EnvMgObj = (char *)r;
    - EnvMgLen = -1;
    + EnvMgObjSet(r);
    + EnvMgLenSet(-1);

    #ifdef MP_PERL_HV_GMAGICAL_AWARE
    MP_TRACE_e(MP_FUNC, "[%s/0x%lx] tie %%ENV, $r\n\t (%s%s)",
    @@ -414,7 +417,7 @@

    void modperl_env_request_untie(pTHX_ request_rec *r)
    {
    - EnvMgObj = NULL;
    + EnvMgObjSet(NULL);

    #ifdef MP_PERL_HV_GMAGICAL_AWARE
    MP_TRACE_e(MP_FUNC, "[%s/0x%lx] untie %%ENV; # from r\n\t (%s%s)",


    Let me know if it does fix your problem, and I'll apply it.

    --------------------------------------------------------------------------------
    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
  • Philip M. Gollucci at Dec 16, 2005 at 3:09 pm

    Philip M. Gollucci wrote:
    You will only get the Seg fault or Bus error when a process comes round
    for recycling.
    This is basically caused by the assumption that %ENV will be tied, and local %ENV
    breaks that assumption ;-S

    The following patch fixes this problem for me:
    [patch snipped]

    Somewhere along the way you lost a type cast
    [ttyp1] pgollucci@p6m7g8.office.tmcs
    /home/pgollucci/dev/repos/asf/perl/modperl/5.8.7_svn_prefork/src/modules/perl
    rv=0 185 >make
    cc
    -I/usr/home/pgollucci/dev/repos/asf/perl/modperl/5.8.7_svn_prefork/src/modules/perl
    -I/usr/home/pgollucci/dev/repos/asf/perl/modperl/5.8.7_svn_prefork/xs
    -I/usr/home/pgollucci/dev/apps/httpd/svn/prefork/include
    -I/usr/home/pgollucci/dev/apps/httpd/svn/prefork/include
    -I/usr/local/include
    -I/usr/home/pgollucci/dev/apps/httpd/svn/prefork/include -pipe
    -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DDEBUGGING -fno-strict-aliasing
    -I/usr/local/include -I/usr/home/pgollucci/dev/apps/perl/5.8.7/lib/CORE
    -DMOD_PERL -Wall -Wmissing-prototypes -Wstrict-prototypes
    -Wmissing-declarations -Werror -DAP_DEBUG -DAP_HAVE_DESIGNATED_INITIALIZER
    -Wdeclaration-after-statement -DMP_COMPAT_1X -DMP_DEBUG -DMP_TRACE
    -DAP_DEBUG -g -O0 -DPIC -fPIC -c modperl_env.c && mv modperl_env.o
    modperl_env.lo
    modperl_env.c: In function `modperl_env_request_tie':
    modperl_env.c:407: warning: assignment from incompatible pointer type
    *** Error code 1

    Stop in
    /usr/home/pgollucci/dev/repos/asf/perl/modperl/5.8.7_svn_prefork/src/modules/perl.


    #define EnvMgObjSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_ptr = val;
    }

    Should be

    #define EnvMgObjSet(val) { if (EnvMgOK) SvMAGIC((SV*)ENVHV)->mg_ptr =
    (char *) val;
    }


    With the above change this fixes it for me on a variety of different
    httpd/perl/mod_perl combos on FreeBSD.


    ------------------------------------------------------------------------
    "Love is not the one you can picture yourself marrying,
    but the one you can't picture the rest of your life without."

    "It takes a minute to have a crush on someone, an hour to like someone,
    and a day to love someone, but it takes a lifetime to forget someone..."

    Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
    Consultant / http://p6m7g8.net/Resume/resume.shtml
    Senior Software Engineer - TicketMaster - http://ticketmaster.com
  • Philippe M. Chiasson at Dec 16, 2005 at 9:22 pm

    Philip M. Gollucci wrote:
    Philip M. Gollucci wrote:
    You will only get the Seg fault or Bus error when a process comes round
    for recycling.

    This is basically caused by the assumption that %ENV will be tied, and
    local %ENV
    breaks that assumption ;-S

    The following patch fixes this problem for me:
    [patch snipped]

    Somewhere along the way you lost a type cast
    [...]
    modperl_env.c && mv modperl_env.o modperl_env.lo
    modperl_env.c: In function `modperl_env_request_tie':
    modperl_env.c:407: warning: assignment from incompatible pointer type
    *** Error code 1

    Stop in
    /usr/home/pgollucci/dev/repos/asf/perl/modperl/5.8.7_svn_prefork/src/modules/perl.
    Fixed up my patch and beautified it a bit. Checked in as r357236.
    With the above change this fixes it for me on a variety of different
    httpd/perl/mod_perl combos on FreeBSD.
    It also fixed it on a large combination of Linux configurations for me.

    My compiler didn't catch that missing cast. What version of gcc are you
    using ?

    --------------------------------------------------------------------------------
    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
  • Philip M. Gollucci at Dec 16, 2005 at 9:33 pm

    My compiler didn't catch that missing cast. What version of gcc are you
    using ?
    pgollucci@freebsd.p6m7g8.net /home/pgollucci 1>gcc -v
    Using built-in specs.
    Configured with: FreeBSD/i386 system compiler
    Thread model: posix
    gcc version 3.4.4 [FreeBSD] 20050518

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmodperl @
categoriesmodperl, perl
postedDec 13, '05 at 4:47p
activeDec 16, '05 at 9:33p
posts10
users3
websiteperl.apache.org

People

Translate

site design / logo © 2018 Grokbase