[mod_python] OS X / Apache 2 / mod_python bug

Jamie Kirkpatrick jkp at kirkconsulting.co.uk
Wed Mar 16 14:03:16 EST 2005


On 16 Mar 2005, at 10:05, Graham Dumpleton wrote:

>
> On 16/03/2005, at 8:42 PM, Jamie Kirkpatrick wrote:
>
>> Next after a restart:  just after restarting, before calling 
>> anything I check the logs -
>>
>> [Wed Mar 16 09:33:26 2005] [error] interpreter name that was passed 
>> is:
>> [Wed Mar 16 09:33:26 2005] [error] interpreter name that was passed 
>> is:
>> [Wed Mar 16 09:33:26 2005] [error] interpreter name that was passed 
>> is:
>> [Wed Mar 16 09:33:26 2005] [error] interpreter name that was passed 
>> is:
>> [Wed Mar 16 09:33:26 2005] [error] interpreter name that was passed 
>> is:
>>
>> A minute or so later I check back and i see
>>
>> [Wed Mar 16 09:33:32 2005] [warn] child process 25283 still did not 
>> exit, sending a SIGTERM
>> [Wed Mar 16 09:33:32 2005] [warn] child process 25284 still did not 
>> exit, sending a SIGTERM
>> [Wed Mar 16 09:33:32 2005] [warn] child process 25285 still did not 
>> exit, sending a SIGTERM
>> [Wed Mar 16 09:33:32 2005] [warn] child process 25286 still did not 
>> exit, sending a SIGTERM
>> [Wed Mar 16 09:33:32 2005] [warn] child process 25287 still did not 
>> exit, sending a SIGTERM
>
> In one place in the code, it passed NULL for the interpreter name so
> the code you added to log the name is probably causing the crash. You
> thus may need to do something like:
>
>   if (name != NULL)
>     ... log that name is NULL
>   else
>     ... log the name
>
> BTW, can you confirm that you have the Mac OS X fix for Python 2.3 
> (standard)
> that I have previously mentioned. If you have applied the patch, in 
> python_init()
> there will be:
>
>     /* initialize global Python interpreter if necessary */
>     if (initialized == 0 || ! Py_IsInitialized())
>     {
>         initialized = 1;
>
> where as unpatched mod_python has:
>
>     /* initialize global Python interpreter if necessary */
>     if (! Py_IsInitialized())
>     {
>

I'm unpatched...I tried first by making the alteration to the logging 
of name and including the other logging statement shown below.

<snip>

> /* initialize global Python interpreter if necessary */
>     if (! Py_IsInitialized())
>     {
>
>        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, srv,
>              "Performing Initialisation.");

So, after a normal start error log shows:

[Wed Mar 16 11:03:43 2005] [notice] mod_python: Creating 32 session 
mutexes based on 150 max processes and 0 max threads.
[Wed Mar 16 11:03:43 2005] [error] Performing Initialisation.
[Wed Mar 16 11:03:43 2005] [notice] Digest: generating secret for 
digest authentication ...
[Wed Mar 16 11:03:43 2005] [notice] Digest: done
[Wed Mar 16 11:03:44 2005] [notice] Apache/2.0.53 (Unix) DAV/2 
mod_python/3.1.3 Python/2.4 configured -- resuming normal operations

Then I call the test script:

[Wed Mar 16 11:04:52 2005] [error] The name passed was:
[Wed Mar 16 11:04:52 2005] [error] thegrove.homeip.net
[Wed Mar 16 11:04:53 2005] [notice] mod_python: (Re)importing module 
'test'
[Wed Mar 16 11:04:53 2005] [error] start import
[Wed Mar 16 11:04:53 2005] [error] end import
[Wed Mar 16 11:04:53 2005] [error] start handler
[Wed Mar 16 11:04:53 2005] [error] end handler
[Wed Mar 16 11:04:53 2005] [error] Name was NULL.

Cool - fixed that crash (my fault!), but it still puzzles me why the 
handler gets called again here.

Now a restart - the following is added to the logs:

[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:01 2005] [error] Name was NULL.
[Wed Mar 16 11:06:07 2005] [notice] SIGHUP received.  Attempting to 
restart
[Wed Mar 16 11:06:07 2005] [notice] mod_python: Creating 32 session 
mutexes based on 150 max processes and 0 max threads.
[Wed Mar 16 11:06:07 2005] [notice] Digest: generating secret for 
digest authentication ...
[Wed Mar 16 11:06:07 2005] [notice] Digest: done
[Wed Mar 16 11:06:08 2005] [notice] Apache/2.0.53 (Unix) DAV/2 
mod_python/3.1.3 Python/2.4 configured -- resuming normal operations

Again I have multiple instances of httpd running now ... is this normal?

Now to make the call again:

[Wed Mar 16 11:08:09 2005] [error] The name passed was:
[Wed Mar 16 11:08:09 2005] [error] thegrove.homeip.net
[Wed Mar 16 11:08:09 2005] [error] python_handler: interpreters 
dictionary not initialised.

Same results as before - at least we eliminated the crash i introduced! 
  Next I tried compiling again with the os x patch started normal and 
pulled up the page - this yields the same log as what i have posted 
above.  Now the restart - again, the same logs as i posted above, and 
pulling up the page works!

So, basically, it seems that I have been unfortunate enough not to have 
stumbled on your patch when I was working on this.  Is there any reason 
it hasn't been rolled into the main trunk yet?  A few #IFDEF DARWIN or 
suchlike could surely allow the inclusion of such a patch.  I will take 
the immediate measure of posting my findings to the darwinports mailing 
lists in order to make them aware of the issue and the fix.  I have to 
say, that from the point of view of an OS X user it would be useful to 
at least mention the patch in one of the docs in the main disto.  I 
appologise for seemingly wasting your time, but I honestly spent days 
on this and never stumbled on that patch - the only patches I saw were 
for the Makefile's.

Many thanks for all your time and effort - it has been educational for 
me at least!  I would like to hear whether or not this patch will in 
some way be added to the main release anyway.

Cheers Graham

Jamie



More information about the Mod_python mailing list