-
Notifications
You must be signed in to change notification settings - Fork 705
Segmentation fault with auto instrumentation in asgi applications #2030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report and reproducible example. Could you please also attach a traceback of the failure? |
The container exits with 139. These are the logs
|
Immediate difference that I see is that the message "Queue is full, likely spans will be dropped." occurs twice with automatic instrumentation, but only once with manual instrumentation. |
Does this only when auto instrumenting and not with manual setup? From the logs, it does look like that the tracing pipeline is set up twice. Not sure if that is the issue though. Can you please try setting |
This only happens with auto instrumentation, not manual. I set OTEL_BSP_MAX_QUEUE_SIZE=999999 and segfault still occurs. No change in the amount of time it takes. The only difference is that the queue full message does not appear before the segfault occurs. |
Thanks. That means the queue is not the issue. My initial naive guess is that somehow we are instrumenting things multiple times and that is causing weird memory access issues. Ill try to reproduce with you example and debug later this week. |
I tried to run this on my machine. I could recreate the issue. Here is the stack trace with more info srikanthc@FL-LPT-388s-MacBook-Pro opentelemetry-segfault-example % docker run -it -p 8000:8000 --entrypoint scripts/auto otseg
[2021-08-12 01:21:14 +0000] [7] [INFO] Starting gunicorn 20.1.0
[2021-08-12 01:21:14 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7)
[2021-08-12 01:21:14 +0000] [7] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2021-08-12 01:21:14 +0000] [13] [INFO] Booting worker with pid: 13
WARNING:opentelemetry.trace:Overriding of current TracerProvider is not allowed
[2021-08-12 01:21:14 +0000] [13] [INFO] Started server process [13]
[2021-08-12 01:21:14 +0000] [13] [INFO] Waiting for application startup.
[2021-08-12 01:21:14 +0000] [13] [INFO] Application startup complete.
Fatal Python error: Segmentation fault
Thread 0x00007fc5877fe700 (most recent call first):
File "/usr/local/lib/python3.8/threading.py", line 306 in wait
File "/usr/local/lib/python3.8/site-packages/opentelemetry/sdk/trace/export/__init__.py", line 230 in worker
File "/usr/local/lib/python3.8/threading.py", line 870 in run
File "/usr/local/lib/python3.8/threading.py", line 932 in _bootstrap_inner
File "/usr/local/lib/python3.8/threading.py", line 890 in _bootstrap
Thread 0x00007fc58f627740 (most recent call first):
File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 357 in sleep
File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 209 in run
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 72 in run
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 231 in run
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 67 in run
File "/usr/local/bin/gunicorn", line 8 in <module>
scripts/auto: line 2: 7 Segmentation fault opentelemetry-instrument gunicorn -c gunicorn_conf.py auto_main:app |
gunicorn_config.py already sets up the tracing pipeline and I see opentelemtry-distro is installed as well meaning the instrument command would definitely setup two pipeline. We should update docs to not recommend using the instrument command with gunicorn but instead enable the instrumentations in gunicorn_config.py. I think that should solve this specific issue. That said, we still want to support setting up multiple pipelines when a user really wants it so we should figure out if setting up multiple pipelines is actually what causes the issue and fix it. |
Interestingly I am unable to reproduce this issue if I don't use docker. |
I'm experiencing a similar error in production:
I have seen this quite often during the day, though at irregular intervals. We do have a quite complex instrumentation setup that's entirely manual. Versions:
And these are the OpenTelemetry packages we use directly:
I checked the changelog for the newer versions of the library but I haven't seen anything related. Any ideas? |
There wasn't an exact fix, but there were many related fixes that happened. Can you check if this still happens on |
@srikanthccv thanks for the tip! I will attempt to upgrade and report back :-) It'll take a bit as it's not a smooth upgrade |
Hi @srikanthccv, unfortunately it didn't work. It might be due to OpenTelemetry's interaction with Sentry SDK within the Flask app, I've also tried to invert the order of the initialization of the two but nothing gained. I'll try using a CPU and memory profiler to see if I can get to the bottom of this. Thanks in the meantime! |
I think I have managed to hit same (or very similar)
Full trace: My case is similar to OP, because the unit tests are distributed by |
Given that the issue occurred in older pythons that don't accept bug fixes any more, and could not be reproduced in newer pythons, I recommend that this issue be closed. |
Describe your environment I am experiencing a segmentation fault when using auto instrumentation with any asgi application. I have tested with both starlette and fastapi.
Steps to reproduce
Can be created with the following repo. Steps in README.md. https://github.com/potatochip/opentelemetry-segfault-example
What is the expected behavior?
No segfault
What is the actual behavior?
Segfault
Additional context
Load testing sometimes needs to happen a couple times before a segfault occurs, but usually happens on the first try.
The text was updated successfully, but these errors were encountered: