You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Jie Gao <J....@isu.usyd.edu.au> on 2004/04/03 06:35:57 UTC

Re: [mp2] bug report: modperl_env.c



On Tue, 30 Mar 2004, Stas Bekman wrote:

> Date: Tue, 30 Mar 2004 19:23:06 -0800
> From: Stas Bekman <st...@stason.org>
> To: Jie Gao <ji...@mail.usyd.edu.au>
> Cc: dev@perl.apache.org
> Subject: Re: [mp2] bug report: modperl_env.c
>
> Jie Gao wrote:
> > -------------8<---------- Start Bug Report ------------8<----------
> > 1. Problem Description:
> >
> > Apache segmentation faults trying to run a registry script.
>
> Thanks for the detailed report Jie, but how do we reproduce it without the
> test script and relevant configuration?

Hmm. There is always something else that's missing. :-)  But this time it
involves a big script, which is cgiproxy at http://www.jmarshall.com/tools/cgiproxy/.

I have a simple authentication handler, which runs well without any
problem for many years. CGIproxy also runs by itself, but putting it
under authentication causes this problem.

Regards,



Jie

>
> [...]
> > root@host_name/usr/local/apache:> truss -f bin/httpd -k start -DSSL -X
> >
> >
> > ....
> >
> > 10075/12:       open("/usr/local/apache_2.0.49/htdocs/test2/mobile_proxy/nph-proxy.cgi", O_RDONLY) = 13
> > 10075/12:       read(13, " # ! / u s r / l o c a l".., 4096)    = 4096
> > 10075/12:       close(13)                                       = 0
> > 10075/12:       getpid()                                        = 10075 [10074]
> > 10075/12:       stat("/usr/local/apache_2.0.49/htdocs/010110A/x-proxy/start", 0xFDBFB4F8) Err#2 ENOENT
> > 10075/12:       lstat("/usr", 0xFDBFB488)                       = 0
> > 10075/12:       lstat("/usr/local", 0xFDBFB488)                 = 0
> > 10075/12:       stat("/usr/local", 0xFDBFB420)                  = 0
> > 10075/12:       lstat("/usr/local/apache_2.0.49", 0xFDBFB488)   = 0
> > 10075/12:       lstat("/usr/local/apache_2.0.49/htdocs", 0xFDBFB488) = 0
> > 10075/12:       lstat("/usr/local/apache_2.0.49/htdocs/010110A", 0xFDBFB488) Err#2 ENOENT
> > 10075/12:       dup(14)                                         = 13
>
> what's fd 14? earlier trace?
>
> > 10075/12:       fstat64(13, 0x015E4460)                         = 0
> > 10075/12:       fcntl(13, F_SETFD, 0x00000001)                  = 0
> > 10075/12:       llseek(14, 0, SEEK_CUR)                         = 1176438
> > 10075/12:       close(14)                                       = 0
> > 10075/12:       dup(12)                                         = 14
> > 10075/12:       fstat64(14, 0x015E4460)                         = 0
> > 10075/12:       fcntl(14, F_SETFD, 0x00000001)                  = 0
> > 10075/12:       dup(12)                                         = 15
> > 10075/12:       close(15)                                       = 0
> > 10075/12:       close(12)                                       = 0
> > 10075/12:           Incurred fault #6, FLTBOUNDS  %pc = 0xFEA9BBBC
> > 10075/12:             siginfo: SIGSEGV SEGV_MAPERR addr=0x00000010
> > 10075/12:           Received signal #11, SIGSEGV [default]
> > 10075/12:             siginfo: SIGSEGV SEGV_MAPERR addr=0x00000010
> >
> > ---------------------------------------------------------------------------
> >
> > root@host_name/usr/local/apache/bin:1008> gdb ./httpd
> > GNU gdb 5.0
> > Copyright 2000 Free Software Foundation, Inc.
> > GDB is free software, covered by the GNU General Public License, and you are
> > welcome to change it and/or distribute copies of it under certain conditions.
> > Type "show copying" to see the conditions.
> > There is absolutely no warranty for GDB.  Type "show warranty" for details.
> > This GDB was configured as "sparc-sun-solaris2.9"...
> > (gdb) run -X -f /usr/local/apache/conf/httpd.conf -k start -DSSL -X
> > Starting program: /u0/local/apache_2.0.49/bin/./httpd -X -f /usr/local/apache/conf/httpd.conf -k start -DSSL -X
> > [New LWP 1]
> > [New LWP 2]
> > [New LWP 3]
> > [New LWP 4]
> > [New LWP 5]
> > [New LWP 6]
> > [New LWP 7]
> > [New LWP 8]
> > [New LWP 9]
> > [New LWP 10]
> > [New LWP 11]
> > [New LWP 12]
> > [New LWP 13]
> > [LWP 2 exited]
> > [New LWP 2]
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > [Switching to LWP 12]
> > 0xfea9bbbc in modperl_env_request_tie (my_perl=0x1026fe0, r=0x17a8c78) at modperl_env.c:355
> > 355         EnvMgObj = (char *)r;
> > (gdb)
>
> and you forgot to run 'bt' or 'where' inside gdb.
>
> Though one needs to be careful with threads. Signals aren't necessarily
> delivered to the thread that has sent the signal. So it's quite possible that
> some other thread has caused the segfault and what you see in gdb is just
> where the thread 12 happened to be at the moment. Are you sure that this is
> the only request you were running?
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] bug report: modperl_env.c

Posted by Stas Bekman <st...@stason.org>.
Jie Gao wrote:
> (gdb) run -X -f /usr/local/apache/conf/httpd.conf -k start -DSSL -X
> Stas wrote:
> 
> 
>>Thanks for the trace with args, Jie, but it gives no new info.
>>
>>Program received signal SIGSEGV, Segmentation fault.
>>[Switching to LWP 12]
>>0xfea9bbbc in modperl_env_request_tie (my_perl=0x1026fe0, r=0x17a8c78) at
>>modperl_env.c:355
>>355         EnvMgObj = (char *)r;
>>
>>
>>which expands to:
>>
>>SvMAGIC((SV*)((((XPVGV*)(my_perl->Ienvgv->sv_any))->xgv_gp)->gv_hv))->mg_ptr = (char *)r;
>>
>>so it's possible that my_perl->Ienvgv (which is PL_envgv) is corrupted, or any of the following members:
>>
>>What do you get:
>>
>>gdb> print my_perl->Ienvgv
>>gdb> print *my_perl->Ienvgv
[...]
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to LWP 12]
> 0xfea9bbbc in modperl_env_request_tie (my_perl=0x157b098, r=0x16911a0) at modperl_env.c:355
> 355         EnvMgObj = (char *)r;
> (gdb) bt
> #0  0xfea9bbbc in modperl_env_request_tie (my_perl=0x157b098, r=0x16911a0) at modperl_env.c:355
> #1  0xfea7edf8 in modperl_response_handler_cgi (r=0x16911a0) at mod_perl.c:934
> #2  0xe4864 in ap_run_handler (r=0x16911a0) at config.c:151
> #3  0xe5488 in ap_invoke_handler (r=0x16911a0) at config.c:358
> #4  0x9190c in ap_process_request (r=0x16911a0) at http_request.c:246
> #5  0x88b74 in ap_process_http_connection (c=0x1683260) at http_core.c:250
> #6  0xfa390 in ap_run_process_connection (c=0x1683260) at connection.c:42
> #7  0xfa96c in ap_process_connection (c=0x1683260, csd=0x1683170) at connection.c:175
> #8  0xdef48 in process_socket (p=0x1683138, sock=0x1683170, my_child_num=0, my_thread_num=9,
> bucket_alloc=0x1687148)
>     at worker.c:530
> #9  0xdfacc in worker_thread (thd=0x1e30c8, dummy=0x146a868) at worker.c:844
> #10 0xff050868 in dummy_worker (opaque=0x1e30c8) at thread.c:88
> (gdb) print my_perl->Ienvgv
> $1 = (GV *) 0x0

That was enough ;) PL_envgv is uninitialized. It sounds like a bug in the 
cloning code. I bet if you try with prefork, you won't have this problem.

The following patch tries to workaround it, I don't know how good it is. But 
even if it happens to work, this is a wrong place to do it and I'll need a 
short script/handler that I can reproduce the problem with, so I can come up 
with a good fix in the right place and fix the core perl if there is bug 
there. It'd help us a lot if you could possibly setup and submit a bug 
reporting package using the minimal script/config as explained here:
http://perl.apache.org/docs/2.0/user/help/help.html#Problem_Description

Thanks.

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.212
diff -u -r1.212 mod_perl.c
--- src/modules/perl/mod_perl.c 2 Apr 2004 02:17:45 -0000       1.212
+++ src/modules/perl/mod_perl.c 14 Apr 2004 04:19:14 -0000
@@ -955,6 +955,15 @@
      h_stdin  = modperl_io_override_stdin(aTHX_ r);
      h_stdout = modperl_io_override_stdout(aTHX_ r);

+    if (!PL_envgv) {
+        HV *hv;
+        gv_fetchpv("ENV",TRUE, SVt_PVHV);
+        GvMULTI_on(PL_envgv);
+        hv = GvHVn(PL_envgv);
+       hv_magic(hv, Nullgv, PERL_MAGIC_env);
+    }
+
+    #define EnvMgObj SvMAGIC((SV*)ENVHV)->mg_ptr
      modperl_env_request_tie(aTHX_ r);

      retval = modperl_response_handler_run(r, FALSE);


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] bug report: modperl_env.c

Posted by Jie Gao <J....@isu.usyd.edu.au>.
(gdb) run -X -f /usr/local/apache/conf/httpd.conf -k start -DSSL -X
Stas wrote:

> Thanks for the trace with args, Jie, but it gives no new info.
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to LWP 12]
> 0xfea9bbbc in modperl_env_request_tie (my_perl=0x1026fe0, r=0x17a8c78) at
> modperl_env.c:355
> 355         EnvMgObj = (char *)r;
>
>
> which expands to:
>
> SvMAGIC((SV*)((((XPVGV*)(my_perl->Ienvgv->sv_any))->xgv_gp)->gv_hv))->mg_ptr = (char *)r;
>
> so it's possible that my_perl->Ienvgv (which is PL_envgv) is corrupted, or any of the following members:
>
> What do you get:
>
> gdb> print my_perl->Ienvgv
> gdb> print *my_perl->Ienvgv
>
>
> then I'd continue:
>
> gdb> print my_perl->Ienvgv->sv_any
> gdb> print (XPVGV*)(my_perl->Ienvgv->sv_any)
>
>
> etc.

OK, here is:


Starting program: /u0/local/apache_2.0.49/bin/./httpd -X -f /usr/local/apache/conf/httpd.conf -k start -DSSL -X
[New LWP 1]
[New LWP 2]
[New LWP 3]
[New LWP 4]
[New LWP 5]
[New LWP 6]
[New LWP 7]
[New LWP 8]
[New LWP 9]
[New LWP 10]
[New LWP 11]
[New LWP 12]
[New LWP 13]
[LWP 2 exited]
[New LWP 2]

Program received signal SIGSEGV, Segmentation fault.
[Switching to LWP 12]
0xfea9bbbc in modperl_env_request_tie (my_perl=0x157b098, r=0x16911a0) at modperl_env.c:355
355         EnvMgObj = (char *)r;
(gdb) bt
#0  0xfea9bbbc in modperl_env_request_tie (my_perl=0x157b098, r=0x16911a0) at modperl_env.c:355
#1  0xfea7edf8 in modperl_response_handler_cgi (r=0x16911a0) at mod_perl.c:934
#2  0xe4864 in ap_run_handler (r=0x16911a0) at config.c:151
#3  0xe5488 in ap_invoke_handler (r=0x16911a0) at config.c:358
#4  0x9190c in ap_process_request (r=0x16911a0) at http_request.c:246
#5  0x88b74 in ap_process_http_connection (c=0x1683260) at http_core.c:250
#6  0xfa390 in ap_run_process_connection (c=0x1683260) at connection.c:42
#7  0xfa96c in ap_process_connection (c=0x1683260, csd=0x1683170) at connection.c:175
#8  0xdef48 in process_socket (p=0x1683138, sock=0x1683170, my_child_num=0, my_thread_num=9,
bucket_alloc=0x1687148)
    at worker.c:530
#9  0xdfacc in worker_thread (thd=0x1e30c8, dummy=0x146a868) at worker.c:844
#10 0xff050868 in dummy_worker (opaque=0x1e30c8) at thread.c:88
(gdb) print my_perl->Ienvgv
$1 = (GV *) 0x0
(gdb) print *my_perl->Ienvgv
Cannot access memory at address 0x0
(gdb) print my_perl->Ienvgv->sv_any
Cannot access memory at address 0x0
(gdb) print (XPVGV*)(my_perl->Ienvgv->sv_any)
Cannot access memory at address 0x0


(gdb) where
#0  0xfea9bbbc in modperl_env_request_tie (my_perl=0x157b098, r=0x16911a0) at modperl_env.c:355
#1  0xfea7edf8 in modperl_response_handler_cgi (r=0x16911a0) at mod_perl.c:934
#2  0xe4864 in ap_run_handler (r=0x16911a0) at config.c:151
#3  0xe5488 in ap_invoke_handler (r=0x16911a0) at config.c:358
#4  0x9190c in ap_process_request (r=0x16911a0) at http_request.c:246
#5  0x88b74 in ap_process_http_connection (c=0x1683260) at http_core.c:250
#6  0xfa390 in ap_run_process_connection (c=0x1683260) at connection.c:42
#7  0xfa96c in ap_process_connection (c=0x1683260, csd=0x1683170) at connection.c:175
#8  0xdef48 in process_socket (p=0x1683138, sock=0x1683170, my_child_num=0, my_thread_num=9,
bucket_alloc=0x1687148)
    at worker.c:530
#9  0xdfacc in worker_thread (thd=0x1e30c8, dummy=0x146a868) at worker.c:844
#10 0xff050868 in dummy_worker (opaque=0x1e30c8) at thread.c:88

Regards,



Jie

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] bug report: modperl_env.c

Posted by Stas Bekman <st...@stason.org>.
Jie Gao wrote:

>>>-------------8<---------- Start Bug Report ------------8<----------
>>>1. Problem Description:
>>>
>>>Apache segmentation faults trying to run a registry script.
>>
>>Thanks for the detailed report Jie, but how do we reproduce it without the
>>test script and relevant configuration?
> 
> 
> Hmm. There is always something else that's missing. :-)  But this time it
> involves a big script, which is cgiproxy at http://www.jmarshall.com/tools/cgiproxy/.
> 
> I have a simple authentication handler, which runs well without any
> problem for many years. CGIproxy also runs by itself, but putting it
> under authentication causes this problem.

So, the next step is to start with that problematic script and cut its size to 
the very possible minimum, while it still fails and then post it and the 
relevant configuration here, and circumstances under which we can reproduce 
it. Ideally the tarball to reproduce the bug, mentioned at the bug report 
section would be the best, but if it's too hard please at least try to 
minimize the script first.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org