Segfault under modwsgi but not shell

98 views
Skip to first unread message

Robert Coup

unread,
Nov 10, 2008, 7:01:27 AM11/10/08
to mod...@googlegroups.com
Hey folks,

I have a reproducible segfault for some Django code I've recently moved from Ubuntu Feisty (mod-wsgi 2.0) to Ubuntu Intrepid (mod-wsgi 2.3)... anyway, its a bit complicated so i thought i'd fish here for more ideas before i dig further:

 - its not the libexpat issue
 - the python code uses a ctypes interface to talk to libgeos (a geospatial library)
 - a DB record comes back (postgres/psycopg2) and a ctypes-backed object is constructed
 - accessing a C function with that object (a really simple one) seems to return a bad string, and python explodes.
 - this code normally runs under daemon mode, but the same issue occurs in embedded mode, 1 thread, and with appgroup %{GLOBAL}
 - i can access the DB, build the object, and call the method fine with the same data from an ipython shell
 - other code seems to run fine in the wsgi environment (including other views in the same application)
 - apache is using the worker mpm, same as under feisty
 - mod-wsgi, python2.5, apache 2.2.9, and psycopg2 are straight ubuntu packages under intrepid
 - the unit tests for everything (including the libgeos interface) run fine... ;)

gdb, run -X, and the gdb-python-helpers got me that far.

- Are there other known 'special' libraries like libexpat?
- My next idea is to try it under fastcgi or another apache/python interface (suggestions?)
- Then start dissecting the app until the bahviour changes.
- Any other bright ideas?

Random information is below, not sure if its helpful. All comments appreciated!

Rob :)

(what libgeos depends on)
rcoup@ohia:~$ ldd /usr/lib/libgeos-3.0.0.so
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00002ac866d64000)
        libm.so.6 => /lib/libm.so.6 (0x00002ac867071000)
        libc.so.6 => /lib/libc.so.6 (0x00002ac8672f7000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00002ac867669000)
        /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)

(fairly unhelpful stack trace for teh segfault)
#0  0x00002b5d3c57d6b0 in strlen () from /lib/libc.so.6
#1  0x00002b5d43334fab in PyString_FromString (str=0x56b916a0 <Address 0x56b916a0 out of bounds>)
    at ../Objects/stringobject.c:117
#2  0x00002aaaadbbb348 in ffi_call_unix64 ()
    at /build/buildd/python2.5-2.5.2/Modules/_ctypes/libffi/src/x86/unix64.S:73
#3  0x00002aaaadbba9fc in ffi_call (cif=0x400faad0, fn=0x2aaaadbaf280 <string_at>,
    rvalue=0x400faa10, avalue=0x400fa9f0)
    at /build/buildd/python2.5-2.5.2/Modules/_ctypes/libffi/src/x86/ffi64.c:428
#4  0x00002aaaadbb5545 in _CallProc (pProc=0x2aaaadbaf280 <string_at>, argtuple=0x555557623170,
    flags=<value optimized out>, argtypes=0x555556541680, restype=0x555556568ce0, checker=0x0)
    at /build/buildd/python2.5-2.5.2/Modules/_ctypes/callproc.c:668
#5  0x00002aaaadbae62f in CFuncPtr_call (self=0x5555564e9500, inargs=0x2, kwds=0x0)
    at /build/buildd/python2.5-2.5.2/Modules/_ctypes/_ctypes.c:3363
#6  0x00002b5d432ee763 in PyObject_Call (func=0x56b916a0, arg=0xffffffff, kw=0x2)
    at ../Objects/abstract.c:1861
#7  0x00002b5d433772ac in PyEval_EvalFrameEx (f=0x555557747810, throwflag=<value optimized out>)
    at ../Python/ceval.c:3806
#8  0x00002b5d4337b25d in PyEval_EvalCodeEx (co=0x555556536c60, globals=<value optimized out>,
    locals=<value optimized out>, args=0x2, argcount=1, kws=0x5555577477d8, kwcount=0,
    defs=0x55555653afa8, defcount=1, closure=0x0) at ../Python/ceval.c:2858
#9  0x00002b5d43379920 in PyEval_EvalFrameEx (f=0x555557747630, throwflag=<value optimized out>)
    at ../Python/ceval.c:3691
#10 0x00002b5d4337b25d in PyEval_EvalCodeEx (co=0x55555690f828, globals=<value optimized out>,
    locals=<value optimized out>, args=0x555557563338, argcount=3, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at ../Python/ceval.c:2858
#11 0x00002b5d4331271e in function_call (func=0x55555690fde8, arg=0x555557563320, kw=0x0)
    at ../Objects/funcobject.c:517
#12 0x00002b5d432ee763 in PyObject_Call (func=0x56b916a0, arg=0xffffffff, kw=0x2)
    at ../Objects/abstract.c:1861
#13 0x00002b5d432f29be in PyObject_CallFunctionObjArgs (callable=0x55555690fde8)
    at ../Objects/abstract.c:2091
#14 0x00002aaaadbae661 in CFuncPtr_call (self=0x5555569152a8, inargs=0x1, kwds=0x0)
    at /build/buildd/python2.5-2.5.2/Modules/_ctypes/_ctypes.c:3379
#15 0x00002b5d432ee763 in PyObject_Call (func=0x56b916a0, arg=0xffffffff, kw=0x2)
    at ../Objects/abstract.c:1861
#16 0x00002b5d433772ac in PyEval_EvalFrameEx (f=0x555557747470, throwflag=<value optimized out>)
    at ../Python/ceval.c:3806
#17 0x00002b5d4337b25d in PyEval_EvalCodeEx (co=0x5555564eb3f0, globals=<value optimized out>,
    locals=<value optimized out>, args=0x55555762f7e8, argcount=1, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at ../Python/ceval.c:2858
#18 0x00002b5d4331271e in function_call (func=0x55555694d938, arg=0x55555762f7d0, kw=0x0)
    at ../Objects/funcobject.c:517
#19 0x00002b5d432ee763 in PyObject_Call (func=0x56b916a0, arg=0xffffffff, kw=0x2)
    at ../Objects/abstract.c:1861
#20 0x00002b5d432f236a in PyObject_CallFunction (callable=0x55555694d938,
    format=<value optimized out>) at ../Objects/abstract.c:1892
#21 0x00002b5d433291bb in PyObject_GenericGetAttr (obj=0x55555762fa50, name=0x5555564e3f10)
    at ../Objects/object.c:1356
#22 0x00002b5d43377958 in PyEval_EvalFrameEx (f=0x555557746420, throwflag=<value optimized out>)
    at ../Python/ceval.c:2012
#23 0x00002b5d4337b25d in PyEval_EvalCodeEx (co=0x5555564cf3f0, globals=<value optimized out>,
    locals=<value optimized out>, args=0x5555575635b8, argcount=3, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at ../Python/ceval.c:2858
#24 0x00002b5d4331271e in function_call (func=0x555556a78f50, arg=0x5555575635a0, kw=0x0)
    at ../Objects/funcobject.c:517
#25 0x00002b5d432ee763 in PyObject_Call (func=0x56b916a0, arg=0xffffffff, kw=0x2)

(Libraries apache has loaded at the time of teh crash:)
From                To                  Syms Read   Shared Object Library
0x00002b5d3ba40a50  0x00002b5d3ba588a4  Yes         /lib64/ld-linux-x86-64.so.2
0x000055555557ce00  0x00005555555aab08  Yes         /usr/sbin/apache2
0x00002b5d3bc613e0  0x00002b5d3bc7d818  Yes         /lib/libpcre.so.3
0x00002b5d3be92330  0x00002b5d3bea4968  Yes         /usr/lib/libaprutil-1.so.0
0x00002b5d3c0b7190  0x00002b5d3c0d51a8  Yes         /usr/lib/libapr-1.so.0
0x00002b5d3c2e3240  0x00002b5d3c2eea28  Yes         /lib/libpthread.so.0
0x00002b5d3c5190f0  0x00002b5d3c61e7e8  Yes         /lib/libc.so.6
0x00002b5d3c87a110  0x00002b5d3c8a4e88  Yes         /usr/lib/libldap_r-2.4.so.2
0x00002b5d3cab6ba0  0x00002b5d3cabee38  Yes         /usr/lib/liblber-2.4.so.2
0x00002b5d3cce2d10  0x00002b5d3cdd5998  Yes         /usr/lib/libdb-4.6.so
0x00002b5d3d0092e0  0x00002b5d3d01d558  Yes         /usr/lib/libpq.so.5
0x00002b5d3d274240  0x00002b5d3d2e8388  Yes         /usr/lib/libmysqlclient_r.so.15
0x00002b5d3d62fc60  0x00002b5d3d68b508  Yes         /usr/lib/libsqlite3.so.0
0x00002b5d3d8a2c10  0x00002b5d3d8bc318  Yes         /usr/lib/libexpat.so.1
0x00002b5d3daca5a0  0x00002b5d3dacba68  Yes         /lib/libuuid.so.1
0x00002b5d3dcd12a0  0x00002b5d3dcd5048  Yes         /lib/librt.so.1
0x00002b5d3ded8a30  0x00002b5d3dedede8  Yes         /lib/libcrypt.so.1
0x00002b5d3e110db0  0x00002b5d3e1119d8  Yes         /lib/libdl.so.2
0x00002b5d3e319460  0x00002b5d3e329778  Yes         /usr/lib/libsasl2.so.2
0x00002b5d3e532330  0x00002b5d3e53d9d8  Yes         /lib/libresolv.so.2
0x00002b5d3e763d80  0x00002b5d3e7ce3f8  Yes         /usr/lib/libgnutls.so.26
0x00002b5d3e9f39c0  0x00002b5d3e9ff1d8  Yes         /usr/lib/libtasn1.so.3
0x00002b5d3ec05200  0x00002b5d3ec12328  Yes         /usr/lib/libz.so.1
0x00002b5d3ee22100  0x00002b5d3ee61878  Yes         /lib/libgcrypt.so.11
0x00002b5d3f096530  0x00002b5d3f0c18d8  Yes         /usr/lib/libssl.so.0.9.8
0x00002b5d3f338050  0x00002b5d3f3f27b8  Yes         /usr/lib/libcrypto.so.0.9.8
0x00002b5d3f66f410  0x00002b5d3f6df508  Yes         /usr/lib/libkrb5.so.3
0x00002b5d3f8f8290  0x00002b5d3f8f8dc8  Yes         /lib/libcom_err.so.2
0x00002b5d3fb01070  0x00002b5d3fb20418  Yes         /usr/lib/libgssapi_krb5.so.2
0x00002b5d3fd2b040  0x00002b5d3fd38928  Yes         /lib/libnsl.so.1
0x00002b5d3ff44e50  0x00002b5d3ff873c8  Yes         /lib/libm.so.6
0x00002b5d401c6880  0x00002b5d401c6d18  Yes         /lib/libgpg-error.so.0
0x00002b5d403cef80  0x00002b5d403e2d98  Yes         /usr/lib/libk5crypto.so.3
0x00002b5d405f0cc0  0x00002b5d405f4948  Yes         /usr/lib/libkrb5support.so.0
0x00002b5d407f7ae0  0x00002b5d407f8078  Yes         /lib/libkeyutils.so.1
0x00002b5d438302e0  0x00002b5d43835498  Yes         /lib/libnss_compat.so.2
0x00002b5d43a3a010  0x00002b5d43a400b8  Yes         /lib/libnss_nis.so.2
0x00002b5d43c44fe0  0x00002b5d43c4c718  Yes         /lib/libnss_files.so.2
0x00002b5d43e4fb70  0x00002b5d43e50848  Yes         /lib/libnss_mdns4_minimal.so.2
0x00002b5d44051fe0  0x00002b5d44054a68  Yes         /lib/libnss_dns.so.2
0x00002b5d409ff030  0x00002b5d409ffd58  Yes         /usr/lib/apache2/modules/mod_alias.so
0x00002b5d40c02c30  0x00002b5d40c03278  Yes         /usr/lib/apache2/modules/mod_auth_basic.so
0x00002b5d40e059e0  0x00002b5d40e05ea8  Yes         /usr/lib/apache2/modules/mod_authn_file.so
0x00002b5d41008750  0x00002b5d41008988  Yes         /usr/lib/apache2/modules/mod_authz_default.so
0x00002b5d4120afb0  0x00002b5d4120b6a8  Yes         /usr/lib/apache2/modules/mod_authz_groupfile.so
0x00002b5d4140dc50  0x00002b5d4140e458  Yes         /usr/lib/apache2/modules/mod_authz_host.so
0x00002b5d416108c0  0x00002b5d41610bd8  Yes         /usr/lib/apache2/modules/mod_authz_user.so
0x00002b5d41815400  0x00002b5d41819678  Yes         /usr/lib/apache2/modules/mod_autoindex.so
0x00002b5d41a1eec0  0x00002b5d41a21f68  Yes         /usr/lib/apache2/modules/mod_cgid.so
0x00002b5d41c267a0  0x00002b5d41c28c38  Yes         /usr/lib/apache2/modules/mod_deflate.so
0x00002b5d41e2baa0  0x00002b5d41e2c098  Yes         /usr/lib/apache2/modules/mod_dir.so
0x00002b5d4202ea20  0x00002b5d4202ee18  Yes         /usr/lib/apache2/modules/mod_env.so
0x00002b5d42231f00  0x00002b5d42232948  Yes         /usr/lib/apache2/modules/mod_expires.so
0x00002b5d42436640  0x00002b5d42437c18  Yes         /usr/lib/apache2/modules/mod_mime.so
0x00002b5d4263bea0  0x00002b5d42640368  Yes         /usr/lib/apache2/modules/mod_negotiation.so
0x00002b5d42846530  0x00002b5d4284e558  Yes         /usr/lib/apache2/modules/mod_rewrite.so
0x00002b5d42a52e90  0x00002b5d42a53a08  Yes         /usr/lib/apache2/modules/mod_setenvif.so
0x00002b5d42c605a0  0x00002b5d42c743f8  Yes         /usr/lib/apache2/modules/mod_ssl.so
0x00002b5d42e83220  0x00002b5d42e84c88  Yes         /usr/lib/apache2/modules/mod_status.so
0x00002b5d4308ffc0  0x00002b5d430a5ca8  Yes         /usr/lib/apache2/modules/mod_wsgi.so
0x00002b5d432e6670  0x00002b5d433bc4d8  Yes         /usr/lib/libpython2.5.so.1.0
0x00002b5d4362cdf0  0x00002b5d4362d718  Yes         /lib/libutil.so.1
0x00002aaaaaab4c60  0x00002aaaaaac5cc8  Yes         /lib/libgcc_s.so.1
0x00002aaaaad0dc30  0x00002aaaaad0ed88  Yes         /usr/lib/python2.5/lib-dynload/time.so
0x00002aaaaaf14240  0x00002aaaaaf16768  Yes         /usr/lib/python2.5/lib-dynload/collections.so
0x00002aaaab11bad0  0x00002aaaab11ccb8  Yes         /usr/lib/python2.5/lib-dynload/cStringIO.so
0x00002aaaab363a10  0x00002aaaab3665a8  Yes         /usr/lib/python2.5/lib-dynload/strop.so
0x00002aaaab56ce20  0x00002aaaab579a78  Yes         /usr/lib/python2.5/lib-dynload/cPickle.so
0x00002aaaab7c1700  0x00002aaaab7c7388  Yes         /usr/lib/python2.5/lib-dynload/_socket.so
0x00002aaaab9cfdc0  0x00002aaaab9d0f68  Yes         /usr/lib/python2.5/lib-dynload/_ssl.so
0x00002aaaabbd6ec0  0x00002aaaabbd85b8  Yes         /usr/lib/python2.5/lib-dynload/operator.so
0x00002aaaabe1e9c0  0x00002aaaabe1f718  Yes         /usr/lib/python2.5/lib-dynload/math.so
0x00002aaaac0221c0  0x00002aaaac024128  Yes         /usr/lib/python2.5/lib-dynload/binascii.so
0x00002aaaac2283e0  0x00002aaaac2293c8  Yes         /usr/lib/python2.5/lib-dynload/_random.so
0x00002aaaac42be60  0x00002aaaac42cf28  Yes         /usr/lib/python2.5/lib-dynload/fcntl.so
0x00002aaaac633ab0  0x00002aaaac63d7c8  Yes         /usr/lib/python2.5/lib-dynload/datetime.so
0x00002aaaac889e30  0x00002aaaac88d768  Yes         /usr/lib/python2.5/lib-dynload/array.so
0x00002aaaaca919c0  0x00002aaaaca91cc8  Yes         /usr/lib/python2.5/lib-dynload/_weakref.so
0x00002aaaacd585d0  0x00002aaaacd5b118  Yes         /usr/lib/python2.5/lib-dynload/_struct.so
0x00002aaaacf6a040  0x00002aaaacf77608  Yes         /usr/lib/python2.5/site-packages/psycopg2/_psycopg.so
0x00002aaaad185b40  0x00002aaaad18d148  Yes         /usr/lib/python2.5/site-packages/mx/DateTime/mxDateTime/mxDateTime.so
0x00002aaaad393400  0x00002aaaad393fc8  Yes         /usr/lib/python2.5/lib-dynload/_hashlib.so
0x00002aaaad596c00  0x00002aaaad597278  Yes         /usr/lib/python2.5/lib-dynload/_bisect.so
0x00002aaaad79b4b0  0x00002aaaad79e628  Yes         /usr/lib/python2.5/lib-dynload/itertools.so
0x00002aaaad9a3dc0  0x00002aaaad9a4518  Yes         /usr/lib/python2.5/lib-dynload/_functools.so
0x00002aaaadbac960  0x00002aaaadbbb568  Yes         /usr/lib/python2.5/lib-dynload/_ctypes.so
0x00002aaaaddd4240  0x00002aaaade286b8  Yes         /usr/lib/python2.5/site-packages/numpy/core/multiarray.so
0x00002aaaae04fe00  0x00002aaaae06d358  Yes         /usr/lib/python2.5/site-packages/numpy/core/umath.so
0x00002aaaae27ba60  0x00002aaaae28b1e8  Yes         /usr/lib/python2.5/site-packages/numpy/core/_sort.so
0x00002aaaae4901f0  0x00002aaaae493618  Yes         /usr/lib/python2.5/site-packages/numpy/core/_dotblas.so
0x00002aaaae6a21f0  0x00002aaaae724e08  Yes         /usr/lib/libblas.so.3gf
0x00002aaaae940050  0x00002aaaae9f1978  Yes         /usr/lib/libgfortran.so.3
0x00002aaaaec08cd0  0x00002aaaaec11668  Yes         /usr/lib/python2.5/lib-dynload/parser.so
0x00002aaaaee16820  0x00002aaaaee18208  Yes         /usr/lib/python2.5/lib-dynload/mmap.so
0x00002aaaaf01d160  0x00002aaaaf035748  Yes         /usr/lib/python2.5/site-packages/numpy/core/scalarmath.so
0x00002aaaaf23d180  0x00002aaaaf23f358  Yes         /usr/lib/python2.5/site-packages/numpy/lib/_compiled_base.so
0x00002aaaaf443670  0x00002aaaaf446668  Yes         /usr/lib/python2.5/lib-dynload/bz2.so
0x00002aaaaf6527f0  0x00002aaaaf65ec28  Yes         /lib/libbz2.so.1.0
0x00002aaaaf8635d0  0x00002aaaaf8655b8  Yes         /usr/lib/python2.5/lib-dynload/zlib.so
0x00002aaaafa68da0  0x00002aaaafa69dd8  Yes         /usr/lib/python2.5/lib-dynload/_heapq.so
0x00002aaaafc6e4c0  0x00002aaaafc71598  Yes         /usr/lib/python2.5/site-packages/numpy/linalg/lapack_lite.so
0x00002aaaafe98840  0x00002aaab060beb8  Yes         /usr/lib/liblapack.so.3gf
0x00002aaab093df50  0x00002aaab0945478  Yes         /usr/lib/python2.5/site-packages/numpy/fft/fftpack_lite.so
0x00002aaab0b4e190  0x00002aaab0b7c178  Yes         /usr/lib/python2.5/site-packages/numpy/random/mtrand.so
0x00002aaab0d917c0  0x00002aaab0d98218  Yes         /usr/lib/libgeos_c.so
0x00002aaab0ffe1a0  0x00002aaab108ffe8  Yes         /usr/lib/libgeos-3.0.0.so
0x00002aaab13228b0  0x00002aaab1399116  Yes         /usr/lib/libstdc++.so.6
0x00002aaab15dad80  0x00002aaab15dc458  Yes         /usr/lib/python2.5/lib-dynload/_locale.so
0x00002aaab17df5b0  0x00002aaab17e0708  Yes         /usr/lib/python2.5/lib-dynload/select.so
0x00002aaab19e3ff0  0x00002aaab19e6788  Yes         /usr/lib/python2.5/lib-dynload/_csv.so

(Libraries ipython has loaded after no-crash happens:)
0x00002b7f1e24c240  0x00002b7f1e257a28  Yes         /lib/libpthread.so.0
0x00002b7f1e463db0  0x00002b7f1e4649d8  Yes         /lib/libdl.so.2
0x00002b7f1e667df0  0x00002b7f1e668718  Yes         /lib/libutil.so.1
0x00002b7f1e86de50  0x00002b7f1e8b03c8  Yes         /lib/libm.so.6
0x00002b7f1eb0e0f0  0x00002b7f1ec137e8  Yes         /lib/libc.so.6
0x00002b7f1e027a50  0x00002b7f1e03f8a4  Yes         /lib64/ld-linux-x86-64.so.2
0x00002b7f1ee65a10  0x00002b7f1ee685a8  Yes         /usr/lib/python2.5/lib-dynload/strop.so
0x00002b7f1f0aed80  0x00002b7f1f0b0458  Yes         /usr/lib/python2.5/lib-dynload/_locale.so
0x00002b7f1f2b5ec0  0x00002b7f1f2b75b8  Yes         /usr/lib/python2.5/lib-dynload/operator.so
0x00002b7f1f4bd5d0  0x00002b7f1f4c0118  Yes         /usr/lib/python2.5/lib-dynload/_struct.so
0x00002b7f1f709700  0x00002b7f1f70f388  Yes         /usr/lib/python2.5/lib-dynload/_socket.so
0x00002b7f1f917dc0  0x00002b7f1f918f68  Yes         /usr/lib/python2.5/lib-dynload/_ssl.so
0x00002b7f1fb35530  0x00002b7f1fb608d8  Yes         /usr/lib/libssl.so.0.9.8
0x00002b7f1fdd7050  0x00002b7f1fe917b8  Yes         /usr/lib/libcrypto.so.0.9.8
0x00002b7f200fc200  0x00002b7f20109328  Yes         /usr/lib/libz.so.1
0x00002b7f20313ad0  0x00002b7f20314cb8  Yes         /usr/lib/python2.5/lib-dynload/cStringIO.so
0x00002b7f20519c30  0x00002b7f2051ad88  Yes         /usr/lib/python2.5/lib-dynload/time.so
0x00002b7f20722ab0  0x00002b7f2072c7c8  Yes         /usr/lib/python2.5/lib-dynload/datetime.so
0x00002b7f20978240  0x00002b7f2097a768  Yes         /usr/lib/python2.5/lib-dynload/collections.so
0x00002b7f20bc3e20  0x00002b7f20bd0a78  Yes         /usr/lib/python2.5/lib-dynload/cPickle.so
0x00002b7f20e969c0  0x00002b7f20e96cc8  Yes         /usr/lib/python2.5/lib-dynload/_weakref.so
0x00002b7f21124040  0x00002b7f21131608  Yes         /usr/lib/python2.5/site-packages/psycopg2/_psycopg.so
0x00002b7f2134c2e0  0x00002b7f21360558  Yes         /usr/lib/libpq.so.5
0x00002b7f2157d410  0x00002b7f215ed508  Yes         /usr/lib/libkrb5.so.3
0x00002b7f21805290  0x00002b7f21805dc8  Yes         /lib/libcom_err.so.2
0x00002b7f21a0e070  0x00002b7f21a2d418  Yes         /usr/lib/libgssapi_krb5.so.2
0x00002b7f21c34a30  0x00002b7f21c3ade8  Yes         /lib/libcrypt.so.1
0x00002b7f21e79110  0x00002b7f21ea3e88  Yes         /usr/lib/libldap_r-2.4.so.2
0x00002b7f220b7f80  0x00002b7f220cbd98  Yes         /usr/lib/libk5crypto.so.3
0x00002b7f222d9cc0  0x00002b7f222dd948  Yes         /usr/lib/libkrb5support.so.0
0x00002b7f224e0ae0  0x00002b7f224e1078  Yes         /lib/libkeyutils.so.1
0x00002b7f226e6330  0x00002b7f226f19d8  Yes         /lib/libresolv.so.2
0x00002b7f228faba0  0x00002b7f22902e38  Yes         /usr/lib/liblber-2.4.so.2
0x00002b7f22b0b460  0x00002b7f22b1b778  Yes         /usr/lib/libsasl2.so.2
0x00002b7f22d40d80  0x00002b7f22dab3f8  Yes         /usr/lib/libgnutls.so.26
0x00002b7f22fcf9c0  0x00002b7f22fdb1d8  Yes         /usr/lib/libtasn1.so.3
0x00002b7f231e6100  0x00002b7f23225878  Yes         /lib/libgcrypt.so.11
0x00002b7f23446880  0x00002b7f23446d18  Yes         /lib/libgpg-error.so.0
0x00002b7f2364bb40  0x00002b7f23653148  Yes         /usr/lib/python2.5/site-packages/mx/DateTime/mxDateTime/mxDateTime.so
0x00002b7f238599c0  0x00002b7f2385a718  Yes         /usr/lib/python2.5/lib-dynload/math.so
0x00002b7f23a9f1c0  0x00002b7f23aa1128  Yes         /usr/lib/python2.5/lib-dynload/binascii.so
0x00002b7f23ca5400  0x00002b7f23ca5fc8  Yes         /usr/lib/python2.5/lib-dynload/_hashlib.so
0x00002b7f23eeb3e0  0x00002b7f23eec3c8  Yes         /usr/lib/python2.5/lib-dynload/_random.so
0x00002b7f240eee60  0x00002b7f240eff28  Yes         /usr/lib/python2.5/lib-dynload/fcntl.so
0x00002b7f242f2c00  0x00002b7f242f3278  Yes         /usr/lib/python2.5/lib-dynload/_bisect.so
0x00002b7f2457a4b0  0x00002b7f2457d628  Yes         /usr/lib/python2.5/lib-dynload/itertools.so
0x00002b7f24888e30  0x00002b7f2488c768  Yes         /usr/lib/python2.5/lib-dynload/array.so
0x00002b7f24a96960  0x00002b7f24aa5568  Yes         /usr/lib/python2.5/lib-dynload/_ctypes.so
0x00002b7f24cb6fe0  0x00002b7f24cbe718  Yes         /lib/libnss_files.so.2
0x00002b7f24ed1240  0x00002b7f24f256b8  Yes         /usr/lib/python2.5/site-packages/numpy/core/multiarray.so
0x00002b7f2514ce00  0x00002b7f2516a358  Yes         /usr/lib/python2.5/site-packages/numpy/core/umath.so
0x00002b7f25378a60  0x00002b7f253881e8  Yes         /usr/lib/python2.5/site-packages/numpy/core/_sort.so
0x00002b7f2558d1f0  0x00002b7f25590618  Yes         /usr/lib/python2.5/site-packages/numpy/core/_dotblas.so
0x00002b7f2579f1f0  0x00002b7f25821e08  Yes         /usr/lib/libblas.so.3gf
0x00002b7f25a3d050  0x00002b7f25aee978  Yes         /usr/lib/libgfortran.so.3
0x00002b7f25d06c60  0x00002b7f25d17cc8  Yes         /lib/libgcc_s.so.1
0x00002b7f25f1dcd0  0x00002b7f25f26668  Yes         /usr/lib/python2.5/lib-dynload/parser.so
0x00002b7f2612b820  0x00002b7f2612d208  Yes         /usr/lib/python2.5/lib-dynload/mmap.so
0x00002b7f26332160  0x00002b7f2634a748  Yes         /usr/lib/python2.5/site-packages/numpy/core/scalarmath.so
0x00002b7f26552180  0x00002b7f26554358  Yes         /usr/lib/python2.5/site-packages/numpy/lib/_compiled_base.so
0x00002b7f26758670  0x00002b7f2675b668  Yes         /usr/lib/python2.5/lib-dynload/bz2.so
0x00002b7f269677f0  0x00002b7f26973c28  Yes         /lib/libbz2.so.1.0
0x00002b7f26b785d0  0x00002b7f26b7a5b8  Yes         /usr/lib/python2.5/lib-dynload/zlib.so
0x00002b7f26d7dda0  0x00002b7f26d7edd8  Yes         /usr/lib/python2.5/lib-dynload/_heapq.so
0x00002b7f26f834c0  0x00002b7f26f86598  Yes         /usr/lib/python2.5/site-packages/numpy/linalg/lapack_lite.so
0x00002b7f271ad840  0x00002b7f27920eb8  Yes         /usr/lib/liblapack.so.3gf
0x00002b7f27c52f50  0x00002b7f27c5a478  Yes         /usr/lib/python2.5/site-packages/numpy/fft/fftpack_lite.so
0x00002b7f27e63190  0x00002b7f27e91178  Yes         /usr/lib/python2.5/site-packages/numpy/random/mtrand.so
0x00002b7f280a67c0  0x00002b7f280ad218  Yes         /usr/lib/libgeos_c.so
0x00002b7f283131a0  0x00002b7f283a4fe8  Yes         /usr/lib/libgeos-3.0.0.so
0x00002b7f286378b0  0x00002b7f286ae116  Yes         /usr/lib/libstdc++.so.6
0x00002b7f288eedc0  0x00002b7f288ef518  Yes         /usr/lib/python2.5/lib-dynload/_functools.so
0x00002b7f28af95a0  0x00002b7f28afaa68  Yes         /lib/libuuid.so.1
0x00002b7f28cfe5b0  0x00002b7f28cff708  Yes         /usr/lib/python2.5/lib-dynload/select.so
0x00002b7f28f02ff0  0x00002b7f28f05788  Yes         /usr/lib/python2.5/lib-dynload/_csv.so
0x00002b7f2910edc0  0x00002b7f291184f8  Yes         /usr/lib/python2.5/lib-dynload/_curses.so
0x00002b7f29336f60  0x00002b7f2935c4a8  Yes         /lib/libncursesw.so.5
0x00002b7f2956e7d0  0x00002b7f2956f168  Yes         /usr/lib/python2.5/lib-dynload/termios.so
0x00002b7f29774740  0x00002b7f29775858  Yes         /usr/lib/python2.5/lib-dynload/readline.so
0x00002b7f29994da0  0x00002b7f299b00d8  Yes         /lib/libreadline.so.5
0x00002b7f29bd06a0  0x00002b7f29beccf8  Yes         /lib/libncurses.so.5
0x00002b7f29dfc090  0x00002b7f29dfc788  Yes         /usr/lib/python2.5/lib-dynload/resource.so
0x00002b7f2a3017c0  0x00002b7f2a302be8  Yes         /usr/lib/python2.5/lib-dynload/_lsprof.so
0x00002b7f2a5084a0  0x00002b7f2a50a568  Yes         /usr/lib/python2.5/lib-dynload/unicodedata.so


Robert Coup

unread,
Nov 10, 2008, 3:42:53 PM11/10/08
to mod...@googlegroups.com
On Tue, Nov 11, 2008 at 1:01 AM, Robert Coup <rober...@koordinates.com> wrote:
- My next idea is to try it under fastcgi or another apache/python interface (suggestions?)

Works ok under apache+mod-fastcgi fwiw...

Rob :)

Graham Dumpleton

unread,
Nov 10, 2008, 11:40:03 PM11/10/08
to mod...@googlegroups.com
How many variants of Python do you have installed of 2.5. Ie., is
there both 32 bit and 64 bit versions?

Since you are using ctypes the issue may be byte size or alignment
issues if ctypes code is expecting a certain in memory data structure
layout. This layout may differ between 32 bit and 64 bit architectures
and may be under Apache/mod_wsgi code is running 64 bit where as with
command line Python it isn't, or vice versa.

Other than that, can't think what else to suggest besides trying to
isolate your code out into a very small standalone example to try and
make it easier to debug.

Graham

2008/11/10 Robert Coup <rober...@koordinates.com>:

Robert Coup

unread,
Nov 11, 2008, 1:57:53 AM11/11/08
to mod...@googlegroups.com
Hi Graham,

On Tue, Nov 11, 2008 at 5:40 PM, Graham Dumpleton <graham.d...@gmail.com> wrote:

How many variants of Python do you have installed of 2.5. Ie., is
there both 32 bit and 64 bit versions?

Just the default 64bit python2.5 package from Ubuntu. (sys.maxint==2**63-1) via both mod-wsgi and the shell.

Under feisty the mod-wsgi/geos/apache thing worked fine under both 32bit and 64bit distros, I haven't built a 32bit VM for this app to date.

Other than that, can't think what else to suggest besides trying to
isolate your code out into a very small standalone example to try and
make it easier to debug.

Thanks for your thoughts - I'll see what else I can figure out.

Rob :)

dan90

unread,
Nov 11, 2008, 2:18:26 AM11/11/08
to modwsgi
I've been fighting a nearly identical bug to Robert for a while now
too, in fact, but his greater gdb-fu has got him further. my problem
description of the problem is nearly identical:

My production server, which doesn't have the problem, is Ubuntu Hardy,
64 bit throughout. python 2.5. (Rob, I'm assuming that you have built
a custom mod_wsgi for Feisty, since my modwsgi version for Hardy shows
as 1.3)
my dev server, which crashes reproducably on accessing URLs which load
the GEOS library, is Ubuntu Intrepid, 64 bit throughout also.

Rob, if you make any further progress on solving this I'd love to hear
it. my current MO is basically recompiling things until it works, and
I'll report if i get any luck that way.


cheers,
dan

On Nov 11, 1:40 pm, "Graham Dumpleton" <graham.dumple...@gmail.com>
wrote:
> How many variants of Python do you have installed of 2.5. Ie., is
> there both 32 bit and 64 bit versions?
>
> Since you are using ctypes the issue may be byte size or alignment
> issues if ctypes code is expecting a certain in memory data structure
> layout. This layout may differ between 32 bit and 64 bit architectures
> and may be under Apache/mod_wsgi code is running 64 bit where as with
> command line Python it isn't, or vice versa.
>
> Other than that, can't think what else to suggest besides trying to
> isolate your code out into a very small standalone example to try and
> make it easier to debug.
>
> Graham
>
> 2008/11/10 Robert Coup <robert.c...@koordinates.com>:

Robert Coup

unread,
Nov 11, 2008, 4:56:28 AM11/11/08
to mod...@googlegroups.com
Hey all,

On Tue, Nov 11, 2008 at 8:18 PM, dan90 <dan.ma...@gmail.com> wrote:

I've been fighting a nearly identical bug to Robert for a while now
too, in fact, but his greater gdb-fu has got him further. my problem
description of the problem is nearly identical:

w00t! well. not for you, But i'm glad to know i'm not the only one.
 
My production server, which doesn't have the problem, is Ubuntu Hardy,
64 bit throughout. python 2.5. (Rob, I'm assuming that you have built
a custom mod_wsgi for Feisty, since my modwsgi version for Hardy shows
as 1.3)
my dev server, which crashes reproducably on accessing URLs which load
the GEOS library, is Ubuntu Intrepid, 64 bit throughout also.

Yes, our mod-wsgi 2.0 was custom compiled for feisty.

Latest updates: A really simple wsgi app that does the following for a request explodes nicely in the same way.

from myproject.myapp.models import MyModel

def application(environ, start_response):
    status = '200 OK'
    output = 'boo!\n'

    o = MyModel.objects.get(pk=1)
    g = o.some_geomtry  // boom!

    output += str(g)

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

I wondered if it was something to do with psycopg2 but I just ran the django-gis db & model tests on intrepid and it didn't segfault. The django-gis geos unit tests pass too. Maybe i should run the geos tests inside a wsgi request...

back to my digging...

Rob :)

Robert Coup

unread,
Nov 11, 2008, 5:35:16 AM11/11/08
to mod...@googlegroups.com
On Tue, Nov 11, 2008 at 10:56 PM, Robert Coup <rober...@koordinates.com> wrote:
Maybe i should run the geos tests inside a wsgi request...

They fail inside mod-wsgi. In fact, so does a wsgi application that does:

from django.contrib.gis.geos import GEOSGeometry
g = GEOSGeometry("POINT(0 0)")
s = g.wkt # boom!

So either the pointer being returned from the C constructor is rubbish, and therefore any methods being called with that explode - or the ctypes interface is broken somehow. Another function in the interface - geos_version() - works ok though fwiw.

/me thinks the answer is getting closer, but why only under apache/mod-wsgi?

Rob :)

Graham Dumpleton

unread,
Nov 11, 2008, 5:38:21 AM11/11/08
to mod...@googlegroups.com
2008/11/11 Robert Coup <rober...@koordinates.com>:

Possibly because memory layout is simply different to normal Python interpreter.

I heard of another case once where code under mod_wsgi wasn't working
but would work under fastcgi. Turned out to be a bug in Python cPickle
that only manifested under mod_wsgi.

Graham

dan90

unread,
Nov 11, 2008, 10:22:36 PM11/11/08
to modwsgi
Hm - So could this be some kind of ubuntu bug, or some problem with
minor version releases in upstream [apache|ctypes]. On my servers the
problem manifests never in Ubuntu Hardy (apache 2.2.8, python 2.5.2),
and always in Ubuntu Intrepid (apache 2.2.9, python 2.5.2). Tested
mod_wsgi versions: 2.0, 2.1, 2.3 on both

Rob, have you tried other WSGI hosts than apache/mod_wsgi?

On Nov 11, 7:38 pm, "Graham Dumpleton" <graham.dumple...@gmail.com>
wrote:
> 2008/11/11 Robert Coup <robert.c...@koordinates.com>:
>
>
>
>
>
> > On Tue, Nov 11, 2008 at 10:56 PM, Robert Coup <robert.c...@koordinates.com>

Robert Coup

unread,
Nov 11, 2008, 11:11:57 PM11/11/08
to mod...@googlegroups.com
On Wed, Nov 12, 2008 at 4:22 PM, dan90 <dan.ma...@gmail.com> wrote:

Hm - So could this be some kind of ubuntu bug, or some problem with
minor version releases in upstream [apache|ctypes]. On my servers the
problem manifests never in Ubuntu Hardy (apache 2.2.8, python 2.5.2),
and always in Ubuntu Intrepid (apache 2.2.9, python 2.5.2). Tested
mod_wsgi versions: 2.0, 2.1, 2.3 on both

what versions of GEOS have you tried? manual compiled as well as the ubuntu packaged version? I wonder if there is a test suite for ctypes i can run inside a wsgi request...

Rob, have you tried other WSGI hosts than apache/mod_wsgi?

I've tried:
 apache+mod_wsgi(embedded): fails
 apache+mod_wsgi(daemon): fails
 apache+mod_fastcgi: ok
 python console: ok

I'll have a quick look at mod_python next on my list, then i guess more tracing with valgrind/gdb to figure out what the pointer problem is.

Rob :)

Robert Coup

unread,
Nov 30, 2008, 10:22:15 PM11/30/08
to mod...@googlegroups.com
Back on this again...

On Wed, Nov 12, 2008 at 5:11 PM, Robert Coup <rober...@koordinates.com> wrote:

I'll have a quick look at mod_python next on my list, then i guess more tracing with valgrind/gdb to figure out what the pointer problem is.

Does exactly the same thing under mod_python, fwiw.
 
what versions of GEOS have you tried? manual compiled as well as the ubuntu packaged version? I wonder if there is a test suite for ctypes i can run inside a wsgi request...

Running the ctypes test suite (python/Lib/ctypes/test from py2.5-maint svn) from within a mod_wsgi or a mod_python request completes fine.

I've tried:
 apache+mod_wsgi(embedded): fails
 apache+mod_wsgi(daemon): fails
 apache+mod_fastcgi: ok
 python console: ok

And now:
 apache+mod_python: fails
 apache(prefork mpm) + mod_wsgi: fails (all other tests were worker mpm)

Still looking for bright ideas... I had a browse through the apache, debian, ubuntu, and python bugtrackers but nothing jumped out at me.

Thanks,

Rob :)

Graham Dumpleton

unread,
Dec 2, 2008, 6:32:18 AM12/2/08
to mod...@googlegroups.com
Can you upgrade to Apache 2.2.10. For whatever reason, Apache 2.2.9 on
some systems seems to be causing problems with other Python extension
modules as well. See:

http://groups.google.com/group/django-users/browse_frm/thread/e337057e9df9bb9

Maybe that is same issue you are having.

Graham

2008/12/1 Robert Coup <rober...@koordinates.com>:

idbill

unread,
Dec 2, 2008, 5:41:09 PM12/2/08
to modwsgi
I thought I'd chime in.

Running CentOS 5.2 on a 64-bit machine, responds with a very similar
error as the original poster, but run fine if run on a 32-bit machine
OR from runserver.

At one point I even went and got the latest libffi, but it appears
python doesn't use it anyway... (Some python search I found, someone
complained that the 'internal copy' of libffi in the src tarball was
very old, and shortly after that the config file was set to use the
system installed libffi.)

All the geo and django items were installed from scratch. (see below
for versions and options)
I tried both python 2.5 and 2.6... no go
I tried mod_wsgi and mod_python... no go

Apache is running pre-fork in both cases.

Bill

I have some fairly good instructions as to what I did:
(Note... these very instructions work on a 32-bit machine... but not a
64-bit machine.)

% yum install gcc-c++ zlib-devel
% yum install subversion
- optional
% yum install swig curl
Install Python 2.5.2 or 2.6 from src

% yum install readline-devel
% cd /usr/local/Python-2.x
% ./configure --with-threads --enable-shared
% make
% make install
% cat "/usr/local/lib" >> /etc/ld.so.conf
% ldconfig -N

- install others...
% yum install http
% yum install httpd-devel
% yum install apr-devel

- install mod_wsgi
% cd /usr/local/lib/python2.5/config
% ln -s ../../libpython2.5.so .
% ./configure
% make
% make install

Install Postgres from src

% yum install flex bison bison-devel

% cd /usr/local/postgresql-8.3.4
% ./configure
% make
% make install

% echo /usr/local/postgresql-8.3.4/lib/ > /etc/ld.so.conf.d/pgsql.conf
% echo "PATH:$PATH:/usr/local/pgsql/bin >> ~/.bash_profile
% . ~/.bash_profile
% ldconfig -N

% useradd -c "PostgreSQL User" -m -d /var/lib/pgsql postgres
% mkdir /var/lib/pgsql/data
% chown postgres /var/lib/pgsql/data
% chmod og-rwx /var/lib/pgsql/data

% su - postgres
% echo "PATH:$PATH:/usr/local/pgsql/bin >> ~/.bash_profile
% . .bash_profile
% /usr/local/pgsql/bin/initdb -D /var/lib/pgsql/data

% cp /usr/local/src/postgres_startup_script /etc/init.d/postgres
% cd /etc/rc2.d/
% ln -s ../init.d/postgres S75postgres
% ln -s ../init.d/postgres K75postgres
% cd /etc/rc3.d/
% ln -s ../init.d/postgres S75postgres
% ln -s ../init.d/postgres K75postgres

% echo "/usr/local/pgsql/lib" > /etc/ld.so.conf.d/postgres.conf
% ldconfig -N

- install psycopg2 (postgres python package)
-- add /usr/local/pgsql/bin to root's PATH var
-- may need to edit setup.cfg to add pgsql/include path
% python setup.py build
% python setup.py install


Install GIS from source

% cd /usr/local/src/geos-3.0.2
% ./configure
% make
% make install

% ldconfig -N

% cd /usr/local/src/proj-4.6.1
% ./configure
% make
% make install

% cd /usr/local/src/postgis-1.3.3
% ./configure
% make
% make install

% cd /usr/local/src/gdal-1.5.2
% ./configure
% make
% make install
--- Optional installs:

Install libiconv, then re-install gettext
% yum install gettext gperf autoconf automake ncurses-devel
% cd /usr/local/src/libiconv-1.12
% ./configure
% make
% make install
% cd /usr/local/src/gettext-0.17
% ./configure
% make
% make install

Apache /etc/httpd/conf.d/roadflaw.conf file:

LoadModule wsgi_module modules/mod_wsgi.so

SetEnv PYTHONPATH '/home/django-svn-trunk:/home/roadflaw'
SetEnv GDAL_DATA '/usr/local/share/gdal'

# replace the keywords 'site', 'user', 'group' with your details
ServerName roadflaw.pugetworks.com

WSGIScriptAlias / /home/roadflaw/wsgi.py
WSGIDaemonProcess apache user=apache group=apache processes=5
threads=5
WSGIProcessGroup apache
WSGISocketPrefix run/wsgi

Alias /admin_media /home/django-svn-trunk/django/contrib/admin/media

<Location /admin_media>
Order allow,deny
Allow from all
</Location>

Alias /media /home/roadflaw/media

<Location /media>
Order allow,deny
Allow from all
</Location>

Apache /etc/httpd/conf.d/wsgi.py file:

import sys
import os

sys.path.append( os.path.dirname( os.path.abspath(__file__) ) )
sys.path.append( os.path.dirname( '/home/roadflaw' ) )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Justin Bronn

unread,
Dec 2, 2008, 11:20:29 PM12/2/08
to modwsgi
> WSGIDaemonProcess apache user=apache group=apache processes=5
> threads=5

This could be part of your problem -- it should be `threads=1`. This
is because GEOS is not a thread safe library, and the serialization to
WKT code in particular uses static variables that can cause
unpredictable behavior if multiple threads enter the code at the same
time. Thus, you also made the right choice in choosing a prefork
version of Apache (which Robert should also be using instead of the
worker).

> > I've been fighting a nearly identical bug to Robert for a while now
> > too, in fact, but his greater gdb-fu has got him further. my problem
> > description of the problem is nearly identical:
>
> w00t! well. not for you, But i'm glad to know i'm not the only one.

I've been trying to figure this out as well, wish y'all had told me
sooner! There's something fishy going on with Intrepid's version of
Apache. I was able to get mod_wsgi to deploy on both 32 and 64-bit
versions, but I experienced an exception (on 32-bit) and a segfault
(on 64-bit) as a geometry is transformed when trying to view a record
in the admin. I've created a ticket to document this behavior:

http://code.djangoproject.com/ticket/9694

The patch fixes the exception on 32-bit, but does not fix the segfault
on 64-bit.

For 1.1, I'm doing a minor refactor of the GEOS interface (mostly to
use the non-deprecated IO WKT|WKB reader APIs). I've created a
mercurial repo:

http://geodjango.org/hg/gis-geos/

In my current interface I do not explicitly specify the response type
of character pointers as `c_char_p` this is because ctypes
automatically converts `c_char_p` to Python string objects in the
errcheck function, and thus the memory address is not available to be
freed. My ctypes-fu has improved, and in the refactor I've created a
simple subclass of `c_char_p` -- this prevents conversion to a Python
string object and allows me to free the address, all while explicitly
setting the expected type of the pointer to be returned. When I
replaced with the geos interface refactor, the segfault no longer
occurs on 64-bit (I've yet to do 32-bit as I'm in the midst of
finals). You can check out this changeset for the relevant details:

http://geodjango.org/hg/gis-geos/rev/77f86525906d

Try replacing the geos lib of your django with the one from the repo
and let me know if it also works for you.

Best Regards,
-Justin

Graham Dumpleton

unread,
Dec 2, 2008, 11:37:20 PM12/2/08
to mod...@googlegroups.com
2008/12/3 Justin Bronn <jbr...@gmail.com>:
>
>> WSGIDaemonProcess apache user=apache group=apache processes=5
>> threads=5
>
> This could be part of your problem -- it should be `threads=1`. This
> is because GEOS is not a thread safe library, and the serialization to
> WKT code in particular uses static variables that can cause
> unpredictable behavior if multiple threads enter the code at the same
> time. Thus, you also made the right choice in choosing a prefork
> version of Apache (which Robert should also be using instead of the
> worker).

Whether you use prefork or worker will not make any difference if you
are using mod_wsgi daemon mode and would only be relevant if using
mod_wsgi embedded mode. If the code isn't thread safe, making daemon
processes run with threads=1 would be important for mod_wsgi daemon
mode though. As mod_python only runs in an embedded mode, for it, use
of prefork would also be important.

Graham

Graham Dumpleton

unread,
Dec 2, 2008, 11:57:45 PM12/2/08
to mod...@googlegroups.com
2008/12/3 Graham Dumpleton <graham.d...@gmail.com>:
> 2008/12/3 Justin Bronn <jbr...@gmail.com>:
>>
>>> WSGIDaemonProcess apache user=apache group=apache processes=5
>>> threads=5
>>
>> This could be part of your problem -- it should be `threads=1`. This
>> is because GEOS is not a thread safe library, and the serialization to
>> WKT code in particular uses static variables that can cause
>> unpredictable behavior if multiple threads enter the code at the same
>> time. Thus, you also made the right choice in choosing a prefork
>> version of Apache (which Robert should also be using instead of the
>> worker).
>
> Whether you use prefork or worker will not make any difference if you
> are using mod_wsgi daemon mode and would only be relevant if using
> mod_wsgi embedded mode. If the code isn't thread safe, making daemon
> processes run with threads=1 would be important for mod_wsgi daemon
> mode though. As mod_python only runs in an embedded mode, for it, use
> of prefork would also be important.

FWIW, latest in:

http://groups.google.com/group/django-users/browse_frm/thread/e337057e9df9bb9?hl=en

suggests that nothing to do with threading as has been reproduced in
64 bit mode from ipython. Ie., outside of Apache.

All very confusing.

Robert Coup

unread,
Dec 3, 2008, 5:13:35 AM12/3/08
to mod...@googlegroups.com
Hi Justin,

On Wed, Dec 3, 2008 at 5:20 PM, Justin Bronn <jbr...@gmail.com> wrote:

> WSGIDaemonProcess apache user=apache group=apache processes=5
> threads=5

This could be part of your problem -- it should be `threads=1`.  This
is because GEOS is not a thread safe library, and the serialization to
WKT code in particular uses static variables that can cause
unpredictable behavior if multiple threads enter the code at the same
time.  Thus, you also made the right choice in choosing a prefork
version of Apache (which Robert should also be using instead of the
worker).

i'm well aware of the non-threadsafe-ness - my modwsgi daemon processes run with threads=1, as i did with worker/prefork under the main apache process during testing.
 
I've been trying to figure this out as well, wish y'all had told me
sooner!  There's something fishy going on with Intrepid's version of
Apache.  I was able to get mod_wsgi to deploy on both 32 and 64-bit
versions, but I experienced an exception (on 32-bit) and a segfault
(on 64-bit) as a geometry is transformed when trying to view a record
in the admin.  I've created a ticket to document this behavior:

Did my super-simple case segfault for you (steps: 1. create a GEOSGeometry. 2: call any method on it), or did it only show up via the Django admin?
 
Try replacing the geos lib of your django with the one from the repo
and let me know if it also works for you.

Will give it a go in the morning, thanks a bunch

Rob :)

Justin Bronn

unread,
Dec 3, 2008, 8:42:48 AM12/3/08
to modwsgi
> Did my super-simple case segfault for you (steps: 1. create a GEOSGeometry.
> 2: call any method on it), or did it only show up via the Django admin?

Yes, your simple example segfaulted for me too. And yes, my patch
also fixed it :)

I'm giving a better version of my explanation from last night in the
django-users thread, where I'll also reference a ticket where I'll
attach a patch with the backported changes from that gis-geos repo.

Regards,
-Justin

Justin Bronn

unread,
Dec 3, 2008, 8:52:48 AM12/3/08
to modwsgi
> suggests that nothing to do with threading as has been reproduced in
> 64 bit mode from ipython. Ie., outside of Apache.
>
> All very confusing.
>
> Graham

Forgot to add I agree it's confusing -- especially when the typical
cause of segfaults is running mod_wsgi with threads or mod_python with
Worker + threads. Add to the fact it appears on some distros and not
others and it's an excellent example of a subtle nasty bug. The
ticket is:

http://code.djangoproject.com/ticket/9747

Patch will be attached shortly. Thanks for everyone's help here.

-Justin
Reply all
Reply to author
Forward
0 new messages