On Wed, Nov 6, 2013 at 7:27 AM, Jeff Trawick <traw...@gmail.com> wrote:

> On Wed, Nov 6, 2013 at 4:02 AM, Steve Hay <steve.m....@googlemail.com>wrote:
>
>> On 6 November 2013 00:48, Jeff Trawick <traw...@gmail.com> wrote:
>> > Back to the httpd24threading branch:
>> >
>> > * modperl_interp_pool_select() has this notion of phase, which must
>> either
>> > be startup or request context.
>> > * It thinks it is startup only if the pool passed in is
>> s->process->pconf.
>> > * Sometimes it is passed s->process->pool (parent of pconf), such as
>> from
>> > perl_parse_require_line().
>> > * perl_parse_require_line() can sometimes be called from request
>> context.
>> > * When perl_parse_require_line() calls modperl_interp_pool_select(),
>> request
>> > context can never be identified because perl_parse_require_line() never
>> > passes in r->pool (which I guess would be cmd->pool).
>> > * etc.
>> >
>> > This would seem to be the way to get the right pool to
>> > modperl_interp_pool_select().
>> >
>> > Index: src/modules/perl/modperl_util.c
>> > ===================================================================
>> > --- src/modules/perl/modperl_util.c     (revision 1539040)
>> > +++ src/modules/perl/modperl_util.c     (working copy)
>> > @@ -989,7 +989,7 @@
>> >      int count;
>> >      void *key;
>> >      auth_callback *ab;
>> > -    MP_dINTERP_POOLa(cmd->server->process->pool, cmd->server);
>> > +    MP_dINTERP_POOLa(cmd->pool, cmd->server);
>> >
>> >      if (global_authz_providers == NULL) {
>> >          MP_INTERP_PUTBACK(interp, aTHX);
>> >
>> > That still doesn't bring happiness (no interpreter returned, resulting
>> in a
>> > crash trying to dereference interp).
>> >
>>
>> I'm getting the same crash-on-startup behaviour now myself after a
>> fresh rebuild of everything (now using httpd-2.4.6 and perl-5.19.5). I
>> will look back over the changes made on the threading branch and/or my
>> merges of them into the httpd24 branch. Hopefully the answer lies
>> there somewhere. I'll be very grateful for any help I can get with
>> this though -- I didn't do the original work on either of those
>> branches...
>>
>
> With the "fix" above in place, modperl_init_vhost() seems to be the next
> crucial code.  We go down this path:
>
>     if (base_server == s) {
>         MP_TRACE_i(MP_FUNC, "base server is not vhost, skipping %s",
>                    vhost);
>         return OK;
>     }
>
> and fall through this FIXME in modperl_interp_pool_select():
>
>                 if (!scfg->mip) {
>                     /* FIXME: We get here if global "server_rec" == s,
> scfg->mip
>                      * is not created then. I'm not sure if that's bug or
>                      * bad/good design decicision. For now just return
> NULL.
>                      */
>                     return NULL;
>                 }
>
> (Note: disabling the base_server == s check in modperl_init_vhost() brings
> no happiness either, though perhaps it is a step in the right direction.)
>
> This path is new with httpd 2.4; 2.2 didn't have authz_providers.
>
> This seems to be a whack-a-mole issue.  I'd expect that there is some easy
> way to grab the interpreter for any arbitrary startup path, but I don't see
> it.  Maybe it is worthwhile seeing if we already went through some paths
> where we were able to grab an interpreter.
>

I don't think an interpreter has been created at the point that the require
line is parsed.  (Try setting a breakpoint for modperl_interp_init()).  I
see that some command processors call perl_run() to force early
initialization, but if perl_parse_require_line() calls perl_run() there are
problems later when PerlSwitches is encountered ("mod_perl is already
running, too late for PerlSwitches").

If I bypass this whole issue by avoiding this MP_dINTERP_POOLa in the test
configuration (which apparently has no Perl require???), I get lots of
successful tests.

Index: src/modules/perl/modperl_util.c
===================================================================
--- src/modules/perl/modperl_util.c     (revision 1539040)
+++ src/modules/perl/modperl_util.c     (working copy)
@@ -989,21 +989,26 @@
     int count;
     void *key;
     auth_callback *ab;
-    MP_dINTERP_POOLa(cmd->server->process->pool, cmd->server);
+#if 0
+    int ignored_call_before_macro = modperl_run(); /* must init earlier
than
+                                                    * normal */
+#endif

-    if (global_authz_providers == NULL) {
-        MP_INTERP_PUTBACK(interp, aTHX);
+    if (global_authz_providers == NULL ||
apr_hash_count(global_authz_providers) == 0) {
         return ret;
     }

     apr_pool_userdata_get(&key, AUTHZ_PROVIDER_NAME_NOTE, cmd->temp_pool);
     ab = apr_hash_get(global_authz_providers, (char *) key,
APR_HASH_KEY_STRING
);
     if (ab == NULL || ab->cb2 == NULL) {
-        MP_INTERP_PUTBACK(interp, aTHX);
         return ret;
     }

     {
+    MP_dINTERP_POOLa(cmd->pool, cmd->server);
+
+
+    {
         dSP;
         ENTER;
         SAVETMPS;
@@ -1030,6 +1035,8 @@
     }

     MP_INTERP_PUTBACK(interp, aTHX);
+    }
+
     return ret;
 }

Test Summary Report
-------------------
t\apache\subprocess.t                 (Wstat: 0 Tests: 1 Failed: 0)
  Parse errors: Bad plan.  You planned 5 tests but ran 1.
t\compat\conn_rec.t                   (Wstat: 0 Tests: 2 Failed: 0)
  Parse errors: Bad plan.  You planned 4 tests but ran 2.
t\hooks\authen_digest.t               (Wstat: 0 Tests: 7 Failed: 4)
  Failed tests:  4-7
t\modperl\interpreter.t               (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: Bad plan.  You planned 17 tests but ran 0.
t\modperl\local_env.t                 (Wstat: 0 Tests: 6 Failed: 1)
  Failed test:  6
t\modperl\merge.t                     (Wstat: 0 Tests: 10 Failed: 3)
  Failed tests:  3, 6, 9
t\modperl\merge2.t                    (Wstat: 0 Tests: 10 Failed: 3)
  Failed tests:  3, 6, 9
t\modperl\merge3.t                    (Wstat: 0 Tests: 10 Failed: 3)
  Failed tests:  3, 6, 9
t\modules\cgi.t                       (Wstat: 0 Tests: 5 Failed: 5)
  Failed tests:  1-5
t\modules\cgi2.t                      (Wstat: 0 Tests: 5 Failed: 5)
  Failed tests:  1-5
t\modules\cgipost.t                   (Wstat: 0 Tests: 6 Failed: 5)
  Failed tests:  2-6
t\modules\cgipost2.t                  (Wstat: 0 Tests: 6 Failed: 5)
  Failed tests:  2-6
t\modules\cgiupload.t                 (Wstat: 0 Tests: 2 Failed: 2)
  Failed tests:  1-2
t\modules\cgiupload2.t                (Wstat: 0 Tests: 2 Failed: 2)
  Failed tests:  1-2
t\protocol\echo_block.t               (Wstat: 0 Tests: 3 Failed: 2)
  Failed tests:  2-3
t\protocol\echo_nonblock.t            (Wstat: 0 Tests: 3 Failed: 1)
  Failed test:  2
t\protocol\echo_timeout.t             (Wstat: 0 Tests: 5 Failed: 4)
  Failed tests:  2-5
t\protocol\pseudo_http.t              (Wstat: 0 Tests: 13 Failed: 9)
  Failed tests:  3-8, 11-13
Files=252, Tests=2585, 606 wallclock secs ( 1.48 usr +  0.97 sys =  2.45
CPU)
Result: FAIL
Failed 18/252 test programs. 54/2585 subtests failed.
[warning] server WIN-MOEO9JF0AKP:8529 shutdown
[  error] error running tests (please examine t\logs\error_log)

Hopefully somebody that knows a lot about mod_perl [init] and the threading
changes can think about the ordering issue with require???




>
>> (Not sure how you break into things in your debugger, btw. I find the
>> easiest way is to start up devenv.exe with "devenv /useenv httpd.exe"
>> and then set the command-line arguments in the httpd project to those
>> that "t\TEST -start-httpd" would use, namely something like "-d
>> C:/Dev/Temp/modperl-httpd24threading/t -f
>> C:/Dev/Temp/modperl-httpd24threading/t/conf/httpd.conf -D APACHE2 -D
>> PERL_USEITHREADS -D ONE_PROCESS". Then you can just hit F5 etc to set
>> it running.)
>>
>
> Yeah, that was one of the first things I thought of staring at the ceiling
> this a.m.  Thanks for the shortcut!  No need to chase down the -debug code.
>
>
> --
> Born in Roswell... married an alien...
> http://emptyhammock.com/
>



-- 
Born in Roswell... married an alien...
http://emptyhammock.com/

Reply via email to