3

My django apps works correctly locally, but when I deployed it facing a uswgi seg fault for one specific route. Every others routes works correctly. Here the view:

def bunny(request): """ Filter crawler, bot and real user :param request: :return: serve rendered page to crawler / SPA to user """ ......some other codes .... path = request.get_full_path_info() if path.startswith('/news_paper'): # <<-- seg fault for this routes only in production server news_paper = utils(unquote(path[12:])) if news_paper[1] == 0: # if news paper is not found return default list return render(request, 'site_list.html') news = News.objects.filter(news_paper=news_paper[1]).order_by('-created_at')[:15] return render(request, 'news.html', {'news': news, 'title': news_paper[0]}) elif path == '/about/': return render(request, 'about.html') else: return render(request, 'site_list.html') 

uWsgi conf file:

[uwsgi] chdir=/home/.. home = /home/../.env module=xyz.wsgi master=True process = 5 pidfile=/run/xyz.pid socket= /run/xyz.sock stats=/tmp/xyz.stat vacuum=True max-requests=500 logto = /home/../logs/xyz.log log-maxsize = 200480 uid = prism gid = www-data die-on-term = true chmod-socket = 666 chown-socket = www-data 

and the log file:

!!! uWSGI process 4668 got Segmentation Fault !!! *** backtrace of 4668 *** uwsgi(uwsgi_backtrace+0x2c) [0x46d0ac] uwsgi(uwsgi_segfault+0x21) [0x46d471] /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f1c373b84b0] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(ssl3_cleanup_key_block+0xb) [0x7f1c32d3fcab] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(ssl3_clear+0x16) [0x7f1c32d3d5a6] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(tls1_clear+0x9) [0x7f1c32d49219] /usr/lib/x86_64-linux-gnu/libssl.so.1.1(SSL_new+0x462) [0x7f1c387a5d22] /home../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0x23969) [0x7f1c32fd4969] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0x24fc5) [0x7f1c32fd5fc5] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(PQconnectPoll+0xb78) [0x7f1c32fbfba8] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0xfa28) [0x7f1c32fc0a28] /home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(PQconnectdb+0x1f) [0x7f1c32fc341f] /home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0x12651) [0x7f1c33214651] /home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0x133df) [0x7f1c332153df] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x16cb06) [0x7f1c37af1b06] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_CallFunction_SizeT+0x12c) [0x7f1c37aa9f1c] /home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0xc1a8) [0x7f1c3320e1a8] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyCFunction_Call+0xa6) [0x7f1c37ae2466] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x5ae5) [0x7f1c37b37665] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyEval_EvalCodeEx+0x27d) [0x7f1c37b3114d] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1391aa) [0x7f1c37abe1aa] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyObject_Call+0x47) [0x7f1c37aa8547] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x1aca) [0x7f1c37b3364a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b5253) [0x7f1c37b3a253] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b5253) [0x7f1c37b3a253] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x11b8) [0x7f1c37b32d38] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x132c1b) [0x7f1c37ab7c1b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x13e18c) [0x7f1c37ac318c] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x16cb06) [0x7f1c37af1b06] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4ce7) [0x7f1c37b39ce7] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x13a) [0x7f1c37b3b83a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e) [0x7f1c37aa818e] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61) [0x7f1c37aa8ce1] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1710ee) [0x7f1c37af60ee] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x172285) [0x7f1c37af7285] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1aa2ac) [0x7f1c37b2f2ac] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyCFunction_FastCallDict+0x165) [0x7f1c37ae2235] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4b5b) [0x7f1c37b39b5b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b] /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053] *** end of backtrace *** DAMN ! worker 1 (pid: 4668) died :( trying respawn ... Respawned uWSGI worker 1 (new pid: 4709) 

I am using latest version of django and psycopg2.

1 Answer 1

5

This error occurs when uwsgi and psycopg are compiled against two different openssl versions. You have two solution.

  • disable ssl of django database configuration

    # Database DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'mydb', 'USER': 'myuser', 'PASSWORD': 'mypassword', 'HOST': 'localhost', 'PORT': '', 'OPTIONS': { 'sslmode': 'disable' } } } 
  • Install psyocpg2 from source instead of wheel

to install psyocpg2 from source you have to uninstall previous one and try this

pip uninstall psycopg2 pip install --no-binary :all: psycopg2 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.