Closed jukeks closed 11 months ago
IF UNAME_SYSNAME != "Windows" and PY_VERSION_HEX >= 0x03070000:
cdef PyInterpreterState* interp
cdef PyThreadState* tstate
cdef _PyErr_StackItem* exc_info
cdef PyThread_type_lock lmutex = _PyRuntime.interpreters.mutex
cdef PyObject* exc_type
cdef PyObject* exc_tb
cdef dict running_threads = {}
# This is an internal lock but we do need it.
# See https://bugs.python.org/issue1021318
if PyThread_acquire_lock(lmutex, WAIT_LOCK) == PY_LOCK_ACQUIRED:
Looks like something has changed since 3.11 as the mutex is now NULL
. And it makes sense since 3.12 introduced isolated subinterpreters https://peps.python.org/pep-0684/ .
@jukeks many thanks for the report. Usually for segmentation faults, we ask customers to go through our support portal (you may still do so if you like), but I think you've given ample information here.
Looking into it.
@jukeks thanks for the report and the analysis! Since that lock is required for the current implementation of the collect_threads
function to work, one possible (temporary) solution could be to adopt a pure-Python implementation for 3.12, like the one in https://github.com/P403n1x87/dd-trace-py/blob/d897bfd6b1b1a9ee9c6804276efe2a7b3b07797c/ddtrace/profiling/collector/stack.py.
We have encountered this issue as well with Python 3.12. This is preventing us to migrate to this version of Python at the moment.
Any update on this bug? It's blocking our update to python 3.12
as well
We have just merged https://github.com/DataDog/dd-trace-py/pull/7822 in the main branch and opened backports as far back as 2.1. We should have this fix released with the next patch releases in the coming days.
@jukeks @k4nar @aebrahim the fix is available in v2.3.2, as well as in the latest 2.2 and 2.1 releases. It would be great if you could test that to confirm that the issue has been resolved. Many thanks 🙏
Fixed for me! Thank you!
Summary of problem
Running
uvicorn
throughddtrace-run
with profiling enabled segfaultsAlso same happens with
gunicorn --help
.And core's bt looks like
Which version of dd-trace-py are you using?
Which version of pip are you using?
Which libraries and their versions are you using?
`pip freeze`
aioprometheus==23.3.0 annotated-types==0.6.0 anyio==3.7.1 attrs==23.1.0 Babel==2.13.1 bytecode==0.15.1 cattrs==23.1.2 certifi==2023.7.22 cffi==1.16.0 charset-normalizer==3.3.2 click==8.1.7 confluent-kafka==2.3.0 cryptography==41.0.5 datadog==0.47.0 ddsketch==2.0.4 ddtrace==2.1.5 Deprecated==1.2.14 ecs-logging==2.1.0 envier==0.4.0 exceptiongroup==1.1.3 fastapi==0.104.1 grpc-interceptor==0.15.3 grpcio==1.59.2 grpcio-health-checking==1.59.2 grpcio-reflection==1.59.2 gunicorn==21.2.0 h11==0.14.0 hiredis==2.2.3 httpcore==1.0.1 httptools==0.6.1 httpx==0.25.1 hvac==2.0.0 idna==3.4 importlib-metadata==6.8.0 langcodes==3.3.0 more-itertools==10.1.0 opentelemetry-api==1.21.0 orjson==3.9.10 packaging==23.2 protobuf==4.25.0 py-moneyed==3.0 pycparser==2.21 pydantic==2.4.2 pydantic-settings==2.0.3 pydantic_core==2.10.1 PyJWT==2.8.0 python-dotenv==1.0.0 pytz==2023.3.post1 quantile-python==1.1 redis==5.0.1 requests==2.31.0 sentry-sdk==1.34.0 setuptools==68.2.2 six==1.16.0 sniffio==1.3.0 starlette==0.27.0 statsd==4.0.1 timing-asgi==0.3.1 typing_extensions==4.8.0 urllib3==2.0.7 uvicorn==0.24.0.post1 uvloop==0.19.0 wattr==0.1.33How can we reproduce your problem?
With Python 3.12 run
What is the result that you get?
Segfault.
What is the result that you expected?
Help printout.