[mod_python] apache segfault with mod_python + pysqlite2

Jim Gallacher jpg at jgassociates.ca
Sun Jan 22 11:55:00 EST 2006


Daniel Nogradi wrote:
> (I sent this to the pysqlite mail list as well)
> 
> I have a problem with using pysqlite2 with mod_python (publisher handler).
> Whenever I use a method from pysqlite2 apache segfaults. However, mod_python
> in itself works perfectly well and executes any python code as it should
> (except for pysqlite2 code) and pysqlite2 in itself works also perfectly
> well unless I use it in combination with mod_python. That is, if
> sqlite-code.py contains any pysqlite2 code, then running it from the command
> line by 'python sqlite-code.py' produces no errors and does what it supposed
> to do.
> 
> The only problem is when sqlite-code.py is accessed through a browser, in
> this case apache segfaults and the error_log says:
> 
> [Sun Jan 22 15:17:29 2006] [notice] child pid 3012 exit signal Segmentation
> fault (11)
> 
> Merely importing the pysqlite2 module makes no harm, if
> sqlite-code.pycontains only:
> 
> from pysqlite2 import dbapi2 as sqlite
> def test( req ):
>     return "hello"
> 
> then there will be no segfault and the URL
> http://server/python/sqlite-code/test will nicely output "hello". But if it
> contains the following:
> 
> from pysqlite2 import dbapi2 as sqlite
> def test( req ):
>     con = sqlite.connect( "some.db" )
>     con.close()
>     return "hello"
> 
> then the segfault occurs. Writing permissions for ' some.db' can not be a
> problem, every path was chmoded to 777 and I also tried to connect to
> :memory: with the same result.
> 
> Some info on my settings:
> 
> apache directives:
> 
> <Directory /var/www/html/python>
>     SetHandler python-program
>     PythonHandler mod_python.publisher
>     PythonDebug On
> </Directory>
> 
> versions:
> 
> python 2.3.4-11 (Fedora Core 3 binary rpm package)
> mod_python 3.1.3-5 (Fedora Core 3 binary rpm package)
> httpd 2.0.52-3 (Fedora Core 3 binary rpm package)
> sqlite 3.2.8 (compiled from source)
> pysqlite 2.1.0 (compiled from source)
> 
> And SELinux is disabled.
> 
> Anyone has experienced this before? Also if you run apache + mod_python +
> pysqlite2 and everything works, please let me know your version numbers, I
> would then try to up/downgrade to that.
> 

We often see this sort of segfault when 2 Apache modules are using 
different library version. The usual culprit is php-mysql and the python 
MySQLdb module. Any chance you are using php-sqlite? If so compare the 
lib versions of it your pysqlite module.

Jim


More information about the Mod_python mailing list