Search code examples
pythonsegmentation-faultupgradeuwsgi

uWSGI Segmentation Fault


After upgrading from Debian Stretch to Bullseye (e.g. Python 3.5 → 3.9) we've got the following uWSGI segfault:

uWSGI process 314459 got Segmentation Fault !!!
*** backtrace of 314459 ***
/usr/bin/uwsgi(uwsgi_backtrace+0x2f) [0x558ed0a9b96f]
/usr/bin/uwsgi(uwsgi_segfault+0x23) [0x558ed0a9bd73]
/lib/x86_64-linux-gnu/libc.so.6(+0x3bd60) [0x7fd71a9e0d60]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyErr_Occurred+0xe) [0x7fd7184d247e]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x12d655) [0x7fd718586655]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyType_Lookup+0x2d) [0x7fd71858678d]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(_PyObject_GenericGetAttrWithDict+0x4d) [0x7fd71856a73d]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(+0x1121c9) [0x7fd71856b1c9]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyObject_GetAttrString+0x3b) [0x7fd71856730b]
/usr/lib/x86_64-linux-gnu/libpython3.9.so.1.0(PyObject_HasAttrString+0x7) [0x7fd718567d87]
/usr/lib/uwsgi/plugins/python3_plugin.so(uwsgi_python_autoreloader_thread+0x179) [0x7fd718a04d19]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8ea7) [0x7fd71b2d3ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7fd71aaa2def]
*** end of backtrace ***

How can we find out what is causing this and how to fix the issue?

Disabling psycopg2 SSL mode does not help.


Solution

  • This line in the backtrace made me think that maybe the issue has something to do with automatic reloading:

    /usr/lib/uwsgi/plugins/python3_plugin.so(uwsgi_python_autoreloader_thread+0x179) [0x7fd718a04d19]
    

    Then I found this issue: https://github.com/unbit/uwsgi/issues/1968

    As a workaround I disabled autoreload and the service recovered. According to this page autoreloading is only for development purposes.