Mailing List Archive

mod_python - problem with dynamic loading
Hello!

I need an advice from guru who understands shared libraries issues.

I have Python 1.5.1, Apache 1.3.4 and PyApache 4.14.
Initially I ran all this on Sun, Solaris 2.5.1. All worked pretty good.
Then I tried to move things to linux, but I experienced many troubles.

First time I started apache with pyapache, I did few simple things -
this worked, - and then ran

import cgi
cgi.test()

This failed. I looked into apache's error_log and found an error message
from PyApache error handler: unhandled exception - _Py_SOMETHING not found
(I do not remember exact symbol, but I expected this symbol to be exported
from libpython.a, linked with pyapache).

I looked into pyapache mailing list and found I am not alone:
http://www.egroups.com/group/pyapache-devel/132.html
His have got almost the same configuration (and he, like me, runs
postgres).
I started experiment and removed mod_auth_pgsql from apache. PyApache
worked! This was on Debian 2.1; I tried to move recompile pyapache on
RedHat 5.1. Compiled, but refused to work. Apache's error_log shows:
segmentation fault.
Then I recompiled apache on debian adding mod_auth_pgsql back. PyApache
worked for some time, but then started to do the same segmentation fault.

This time I've got yet another linux - RH 5.2. I am not a sysadmin
there, so instructed a sysadmin how to compile python and pyapache.
PyApache worked on that computer... until I looked into error_log. I found
segmentation faults there. But all my scripts worked, so I think
segmentation fault occurred after a script.
For some reasons apache on the computer was recompiled few times - added
mod_perl, then mod_auth_mysql. PyApache always worked; sometimes there are
segmentation faults, sometimes there are not.

Recently I upgraded my sun and 2 linux systems to python 1.5.2 and
apache 1.3.6. Nothing changed - pyapache worked on sun without minor
trouble, but on Linux _Py_NoneStruct not found or segmentation fault.
"_Py_NoneStruct not found" usually appeared when I am trying to import time
or socket (via urllib or cgi) - python tried to load timemodule.so or
socketmodule.so - and failed. :(

Anyone understand what is going on? Any advice how to fix this?

Oleg.
----
Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/
Programmers don't die, they just GOSUB without RETURN.
mod_python - problem with dynamic loading [ In reply to ]
Oleg Broytmann wrote:
>
> Hello!
>
> I need an advice from guru who understands shared libraries issues.
>
> I have Python 1.5.1, Apache 1.3.4 and PyApache 4.14.
> Initially I ran all this on Sun, Solaris 2.5.1. All worked pretty good.
> Then I tried to move things to linux, but I experienced many troubles.
..snip..

When you link apache, you need to add a command-line switch to export
all of it's symbols to be available to loaded shared objects (so the
.so's can see python symbols). I think it's -rdynamic or -Bshareable
(or something like that, I've been in FreeBSD land for a while. The ld
man page will say which it is).

The other alternative is to compile your python installation statically
(instead of using dynamic modules (.so's)), but the linker switch is
probably what you want.

BTW: you may have to pass the linker switch to gcc as -Xlinker
<linkerswitch> or something like that (like I said, it's been a while).
Of course the gcc man page on this is more authoritative.
--
"There are two major products that come out of Berkeley:
LSD and UNIX. We don't believe this to be a coincidence."
- Jeremy S. Anderson