Re: [sqlite] Segmentation Fault when using mod_python / mod_wsgi

2008-06-18 Thread Eric Holmberg
This is now officially off-topic since the problem is in the Python
SQLite wrappers and Apache instead of the SQLite C code.  Regardless, I
would like to post the cause and solution so that anybody who ends up
here while doing a web search will know the solution.

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1208731424 (LWP 20956)] PyDict_GetItem 
> (op=0x0, key=0xb7c25e4c) at Objects/dictobject.c:571
> 571 if (!PyDict_Check(op))
> (gdb) bt full
> #0  PyDict_GetItem (op=0x0, key=0xb7c25e4c) at 
> Objects/dictobject.c:571
> hash = 5854612
> ep = (dictentry *) 0x595594
> tstate = (PyThreadState *) 0x0
> #1  0x0058da34 in ?? ()
> No symbol table info available.
> #2  0x in ?? ()
> No symbol table info available.
> 
> Since SQLite works fine at the command line and fine with the 
> Python interpreter, but fails when invoked with mod_python 
> and mod_wsgi through Apache, then I'm assuming that there is 
> either an odd threading issue or something is not being setup 
> correctly in the Apache/mod_* chain.

Background
--

I installed SQLite, Python, mod_python, and mod_wsgi from source and
started getting the segmentation faults.  Recompiling Apache from the
http.spec source solved the segmentation fault.  Now I was able to get a
more sane SystemError response when connecting to the SQLite database
(either file-based or memory based).

System Information
--
RHEL AS 4
Apache Version: 2.0.52
SQLite Version: 3.5.9
SQLite Threadsafety: 1
Python Version: 2.5.2
PySQLite Version: 2.3.2
Mod_python Version: 3.3.1
Mod_wsgi Version: 2.0

Executing this code
---
con = sqlite3.connect(':memory:')

Results in the following error
--
SystemError: NULL result without error in PyObject_Call

Cause & Solution

It turns out that this was a symbol clash between the SQLite library
built into Python 2.5 (PySQLite version 2.3.2) and Apache's
mod_mem_cache module.  There are several possible solutions:

 1. Disable the mod_cache and associated mod_*_cash modules in Apache
 2. Install a newer version of PySQLite > 2.3.2 and then do the
following changes

# Change this
import sqlite3

# to this
from pysqlite2 import dbapi2 as sqlite3

 3. Remove the existing sqlite3 module in Python 2.5 and replace it with
a module that does a from pysqlite2.dbapi2 import *

See the following trouble ticket for more info:
 * http://oss.itsystementwicklung.de/trac/pysqlite/ticket/146


I hope this helps somebody out there.

Regards,

Eric Holmberg
Applications Engineer, Arrow Electronics
Denver, Colorado


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Segmentation Fault when using mod_python / mod_wsgi

2008-06-17 Thread Eric Holmberg
> Eric Holmberg wrote:
> > PyDict_GetItem (op=0x0, key=0xb7ce82cc) at Objects/dictobject.c:571
> > 571 if (!PyDict_Check(op))
> 
> You would need to supply more of the backtrace since the 
> calling routine is supplying a null pointer instead of a 
> dictionary.  Nothing points to SQLite being involved so far ...

The full backtrack doesn't provide much info at this point.  I am
attempting to recompile Apache with debugging symbols, but am not
successful as of yet.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208731424 (LWP 20956)]
PyDict_GetItem (op=0x0, key=0xb7c25e4c) at Objects/dictobject.c:571
571 if (!PyDict_Check(op))
(gdb) bt full
#0  PyDict_GetItem (op=0x0, key=0xb7c25e4c) at Objects/dictobject.c:571
hash = 5854612
ep = (dictentry *) 0x595594
tstate = (PyThreadState *) 0x0
#1  0x0058da34 in ?? ()
No symbol table info available.
#2  0x in ?? ()
No symbol table info available.

Since SQLite works fine at the command line and fine with the Python
interpreter, but fails when envoked with mod_python and mod_wsgi through
Apache, then I'm assuming that there is either an odd threading issue or
something is not being setup correctly in the Apache/mod_* chain.

I was just hoping that if this was a thread related issue, that somebody
may have seen this before and have a quick solution.


Build environment / configuration

export CFLAGS='-g '
export LDFLAGS='-g '

SQLite 3.5.9:
./configure --disable-tcl --enable-threadsafe
--enable-cross-thread-connections --enable-debug

Python 2.5.2:
./configure --with-pydebug --enable-shared

Mod_python:
./configure


Thanks,

Eric
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Segmentation Fault when using mod_python / mod_wsgi

2008-06-17 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Eric Holmberg wrote:
> PyDict_GetItem (op=0x0, key=0xb7ce82cc) at Objects/dictobject.c:571
> 571 if (!PyDict_Check(op))

You would need to supply more of the backtrace since the calling routine
is supplying a null pointer instead of a dictionary.  Nothing points to
SQLite being involved so far ...

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIV3BbmOOfHg372QQRAvwiAJ0eeuVG4XhPNvuvLEj/hO0/hZgZSwCdF2ja
gnIQ5EsuA2ElAE02ZSlw9WU=
=tphF
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users