02-28-06 12:46 PM
[ http://issues.apache.org/jira/brows...236
8091 ]
Graham Dumpleton commented on MODPYTHON-109:
--------------------------------------------
Better fix for this if calling of Py_Finalize() is to be eliminated would be
simply not to register python_finalize() function against the child init po
ol. This would be done by deleting line:
apr_pool_cleanup_register(p, NULL, python_finalize, apr_pool_cleanup_null);
from PythonChildInitHandler() function. The whole python_finalize() function
would then no longer be needed and could also be deleted.
If the functionality of registering Python based server cleanup functions we
re to be removed, the server register_cleanup() functions should probably be
left in place as stubs. That is, they would no longer do anything. They sho
uld though log a message in
dicating that they are now deprecated. By not removing them completely, exis
ting code will at least still run. Given that the cleanup functions would no
t have been reliably called in the past and couldn't be relied upon, it shou
ldn't adversely affect any
actual web application that used them.
Feedback on this issue is needed. Any decision about what is done should be
made by all core developers.
> Signal handler calling Py_Finalize() when child processes being killed.
> -----------------------------------------------------------------------
>
> Key: MODPYTHON-109
> URL: http://issues.apache.org/jira/browse/MODPYTHON-109
> Project: mod_python
> Type: Bug
> Components: core
> Versions: 3.2
> Reporter: Graham Dumpleton
> Assignee: Graham Dumpleton
>
> When Apache is killing off child processes as part of actions taken when the "apac
hectl restart" or "apachectl graceful" command is run, it sends a SIGTERM signal to
the child processes. This causes a signal handler registered by Apache to be run. Th
at
signal handler destroys the main child memory pool. That memory pool has though a cleanup ha
ndler associated with it which was registered by mod_python. That cleanup handler ultimately
calls Py_Finalize().
> The problem with this is that Py_Finalize() isn't safe to be called from a signal
handler and if a handler is still executing or there is a separate thread running in
the context of Python, a deadlock will likely ensue. This will prevent the child pr
oce
ss exiting due to the SIGTERM causing the Apache parent process to send it a SIGKILL to real
ly kill it.
> For a more detailed assessment of the problem and what lead to this conclu
sion see:
> http://www.modpython.org/pipermail/...ary/019865.html
> http://www.modpython.org/pipermail/...ary/019866.html
> http://www.modpython.org/pipermail/...ary/019870.html
> To avoid the problem, the only choice seems to be avoid calling Py_Finaliz
e() from the signal handler. The simplistic way of doing this seems to be to
add:
> if (child_init_pool)
> return APR_SUCCESS;
> at the start of python_finalize(). This will mean that Py_Finalize() is never call
ed in child processes. The full consequences of this is unknown, but on face value i
t would seem that it might be a reasonable thing to do. More research may be require
d.
[ Post a follow-up to this message ]
|