mod_wsgi icon indicating copy to clipboard operation
mod_wsgi copied to clipboard

Apache initialization failures due to "mod_wsgi: Unable to stat Python home"

Open pavel-machyniak opened this issue 5 years ago • 0 comments

This happened only on one server, others with the same configuration runs just fine.

We compile apache, mod_swgi and our code on CentOS 7 in 32 bit mode because of compatibility issues.

We found out that it is due to apr_stat, used in wsgi_interp.c file in wsgi_python_init function when checking python home directory. The result in this specific case is APR_INCOMPLETE. Problem in apr_stat is with inode which in this case is bigger than 32 bits and it is handled this way (not returned) in apr_stat because of ABI compatibility.

The recommended solution would be one of:

  1. Ask apr_stat only what is really needed, in this case APR_FINFO_TYPE instead of APR_FINFO_NORM The change would be from: rv = apr_stat(&finfo, python_home, APR_FINFO_NORM, p); to: rv = apr_stat(&finfo, python_home, APR_FINFO_TYPE, p);

  2. If APR_FINFO_NORM is used, accept APR_INCOMPLETE when APR_FINFO_TYPE flag is returned The change would be from: if (rv != APR_SUCCESS) { to if (rv != APR_SUCCESS && !(rv == APR_INCOMPLETE && (finfo.valid & APR_FINFO_TYPE) != 0)) {

pavel-machyniak avatar Jan 13 '20 15:01 pavel-machyniak