1

Operating system - Ubuntu Server 14.04 on Azure VM

Tried with different versions of python (3.4.3, 3.6.0), apache and mod_wsgi.

Installed MS Native ODBC driver using instructions from here https://gist.github.com/joecampo/6f777a659b8132b9d6fe1c3589df394c , while pyodbc was installed using pip.

To debug the wsgi_module I have set up the django application to run in embedded mode and:

gdb /usr/local/apache2/bin/httpd
run -X

When I access any function which imports pyodbc, the wsgi fails with the following error:

Program received signal SIGSEGV, Segmentation fault.
import_types () at src/pyodbcmodule.cpp:223
223 src/pyodbcmodule.cpp: No such file or directory.

Importing module works fine when I run the django app from the command line:

python3 manage.py runserver

Is there a workaround?

Vahagn
  • 386
  • 2
  • 21
  • When you run locally, you may be dependent on ``LD_LIBRARY_PATH`` being set to find a shared library. That environment variable will not be set for mod_wsgi and you can't easily set it so that it is used. What is ``LD_LIBRARY_PATH`` in your local environment? – Graham Dumpleton Feb 21 '17 at 20:50
  • I tried to `echo $LD_LIBRARY_PATH` or run `env`. None returned anything. If I had known what library mod_wsgi cannot find, I could create a soft link in /usr/lib. Is there a way to figure it out? – Vahagn Feb 22 '17 at 05:45
  • If don't have ``LD_LIBRARY_PATH`` set, that is unlikely to be cause. Are you setting ``WSGIApplicationGroup %{GLOBAL}``? The module you are using may simply not work in Python sub interpreters and is crashing. That directive forces use of main interpreter, which is more like what modules see when using command line Python. Also recommend you use daemon mode of mod_wsgi if not already using it. – Graham Dumpleton Feb 22 '17 at 08:02
  • Thanks Graham. I forgot to mention that. Yes I've added WSGIApplicationGroup %{GLOBAL} to the apache configuration. Normally I use mod_wsgi in daemon mode, but now I switched to embedded mode for working with gdb. I compiled apache2 and mod_wsgi with CFLAGS="-g -O" hoping to see a more detailed error with no success, however. – Vahagn Feb 22 '17 at 10:41
  • for /var/log/apport.log ERROR: apport (pid 29205) Wed Feb 22 10:57:41 2017: called for pid 29185, signal 11, core limit 0 ERROR: apport (pid 29205) Wed Feb 22 10:57:41 2017: executable: /usr/sbin/apache2 (command line "/usr/sbin/apache2 -k start") ERROR: apport (pid 29205) Wed Feb 22 10:57:41 2017: is_closing_session(): no DBUS_SESSION_BUS_ADDRESS in environment ERROR: apport (pid 29205) Wed Feb 22 10:57:41 2017: apport: report /var/crash/_usr_sbin_apache2.0.crash already exists and unseen, doing nothing to avoid disk usage DoS – Vahagn Feb 22 '17 at 11:25
  • I have dropped the VM and created a new one. On the fresh VM I installed only unixOdbc 2.3.4 (compiled), pyodbc, django and apache2 together with mod_wsgi. Same issue. Recompiled mod_wsgi for python3 and installed apache2. Please, anybody, say something. – Vahagn Feb 22 '17 at 14:14

2 Answers2

0

I experienced the same problem when setting up a Python Pyramid project, and downgrading to a previous version of pyodbc fixed it.

It looks like this may be a bug in pyodbc or the WSGI module. See pyodbc 4.0.9+ segfault with uwsgi #199. You may already be aware that this line is a red herring:

223 src/pyodbcmodule.cpp: No such file or directory.

That error is coming from the debugger and just tells where in import_types() the exception was raised, however searching for that file led me to that bug report on GitHub.

You obviously already know how to debug Apache and wsgi, but for anyone who doesn't there are detailed instructions here.

Z. Cochrane
  • 101
  • 1
  • 3
0

This has been fixed in 4.0.16 by adding support for subinterpreters.

mkleehammer
  • 366
  • 2
  • 4