[mod_python] OS X / Apache 2 / mod_python bug

Graham Dumpleton grahamd at dscpl.com.au
Wed Mar 16 16:20:30 EST 2005


On 17/03/2005, at 6:03 AM, Jamie Kirkpatrick wrote:

>
> On 16 Mar 2005, at 10:05, Graham Dumpleton wrote:
>> 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.

Am not sure which part of the logs you are referring to, I only see
the handler itself being called once.

> 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?

The lookup of interpreters by NULL is something to do with the
cleanup handlers for the interpreter. Not sure why NULL though.
Can't tell here whether they are in separate processes or not.
Are you using "ps" to note there are multiple processes running.
Because your Apache is running in prefork mode, it is normal for
it to create multiple processes even if not all may be used in
your simple test.

> 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.

I understand the patch is in the subversion repository for the  
mod_python
source code:

    
https://svn.apache.org/repos/asf/httpd/mod_python/trunk/src/ 
mod_python.c

The original person who developed mod_python doesn't really look after  
it
anymore and maintenance has been taken over by someone else. He has been
slowly working through fixing some of the known problems and simply  
hasn't
made an updated release yet. The security fix release done recently was  
a
rush job based on source of previous version. Because there is this
transition to a new maintainer, updating of the web site is also in a  
state
of flux to a degree.

I possibly should point out that although I try and provide help to  
people
on the mailing list, I am not involved in the maintenance of mod_python
itself except as far as I have posted up a lot of bug reports for stuff  
I've
found and possible fixes. I have only been using mod_python for about  
six
months and wasn't intending to get so involved in it nor develop  
Vampire.
I was only after an easier way to construct web pages for my site. I  
really
need to be getting back to my main projects which have been stagnating  
while
on this diversion. :-(

Anyway, outcome from your problem is that I now know that the Mac OS X  
fix
is relevant to the platform generally and not just Apples Python 2.3
installation. Another bit of useful information to help people out.

Graham



More information about the Mod_python mailing list