uWSGI Segmentation Fault When Running with New Relic
Hi,
I am encountering a segmentation fault when running uWSGI with New Relic. The error occurs consistently and results in the following backtrace:
2024-05-28 14:55:54 !!! uWSGI process 20 got Segmentation Fault !!! 2024-05-28 14:55:54 *** backtrace of 20 *** 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_backtrace+0x2f) [0x5555555d925f] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_segfault+0x23) [0x5555555d9623] 2024-05-28 14:55:54 /lib/x86_64-linux-gnu/libc.so.6(+0x38d60) [0x7ffffee99d60] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyThread_CurrentFrames+0x92) [0x7fffff20c498] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(+0x1fc178) [0x7fffff26e178] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(PyObject_Vectorcall+0x38) [0x7fffff2800e8] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyEval_EvalFrameDefault+0x245) [0x7fffff2743d5] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(+0x200e02) [0x7fffff272e02] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(+0x215ecd) [0x7fffff287ecd] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(PyObject_CallFunctionObjArgs+0xad) [0x7fffff2c47dd] 2024-05-28 14:55:54 /usr/local/lib/python3.11/site-packages/newrelic/packages/wrapt/_wrappers.cpython-311-x86_64-linux-gnu.so(+0x5a11) [0x7ffffe044a11] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyObject_MakeTpCall+0x77) [0x7fffff26ca77] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyEval_EvalFrameDefault+0x245) [0x7fffff2743d5] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(+0x200e02) [0x7fffff272e02] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyObject_FastCallDictTstate+0x9c) [0x7fffff26dffc] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyObject_Call_Prepend+0x75) [0x7fffff292145] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(+0x298cfd) [0x7fffff30acfd] 2024-05-28 14:55:54 /usr/local/lib/libpython3.11.so.1.0(_PyObject_Call+0x7b) [0x7fffff292abb] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(python_call+0x10) [0x5555555ecfa0] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_request_wsgi+0x111) [0x5555555ef321] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(wsgi_req_recv+0xad) [0x55555558c17d] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(simple_loop_run+0xc4) [0x5555555d53e4] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(simple_loop+0x6f) [0x5555555d54bf] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_ignition+0x292) [0x5555555d9972] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_worker_run+0x286) [0x5555555ddff6] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(uwsgi_run+0x434) [0x5555555de514] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(+0x378be) [0x55555558b8be] 2024-05-28 14:55:54 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7ffffee84d0a] 2024-05-28 14:55:54 /usr/local/bin/uwsgi(_start+0x2a) [0x55555558b8ea] 2024-05-28 14:55:54 *** end of backtrace ***
Environment:
- uWSGI version: 2.0.25.1
- Python version: 3.11
- Operating System: x86_64 linux
- New Relic agent version: latest version
Steps to Reproduce:
- Install uWSGI with Python 3.11 and the New Relic agent.
- Configure uWSGI with New Relic by setting NEW_RELIC_CONFIG_FILE environment variable.
- Run the application with uWSGI.
- Observe the segmentation fault and backtrace in the logs.
Actual Behavior: uWSGI encounters a segmentation fault, causing the application to crash.
Additional Information: I have verified that the permissions for the New Relic log file are correctly set and that the New Relic agent is properly configured. This issue seems to be related to the integration between uWSGI and the New Relic agent with python 3.11. With python 3.9 i have no problem.
Any assistance in resolving this issue would be greatly appreciated. Thank you!
Please provide the uwsgi configuration
This is the uwsgi config. I'm using uwsgi + nginx + supervisor + flask in a docker machine.
[uwsgi] module = wsgi callable = app_flask
uid = nginx gid = nginx
socket = /tmp/uwsgi.sock chown-socket = nginx:nginx chmod-socket = 664 vacuum = true master = true die-on-term = true cheaper = 2 workers = 10 processes = %(%k + 1) enable-threads = true route = ^/health donotlog: route = ^/nginx_status donotlog:
Supervisor [supervisord] nodaemon=true
[program:uwsgi] command=/usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini --die-on-term ; command=/usr/local/bin/python rest_server.py stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0
[program:nginx] command=/usr/sbin/nginx stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0
flask server { listen 5005;
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
}