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
segfault with gunicorn and a library made with cython bindings #87057
Comments
Here is a simple way to reproduce: from lsm import LSM
db = LSM('db.sqlite')
def app(environ, start_response):
"""Simplest possible application object"""
for (index, (key, value)) in enumerate(db[b'\x00':b'\xFF']):
pass
start_response(b'200', {})
return b''
db.close() In my real program, if I add 'global db' in the function program: https://git.sr.ht/~amirouche/segfault |
I put the code in a "bla.p" script and I ran it with Python 3.8 on Fedora 33: python3.8 -m venv env It doesn't crash. Please provide a script reproducing the issue. Note: lsm-db cannot be installed in Python 3.9 (errors about the removed PyTypeObject.tp_print member in C). |
You need to run the program with the following: python -X dev -c "from gunicorn.app.wsgiapp import run; run()" --workers=1 foobar:app where foobar.py is the code from the previous message. The crash happen when, the function note: lsm package can be installed with pip install lsm-db |
I get a crash without any code, just by running gunicorn. It looks like a bug in gunicorn. --- $ python3.8 -m venv env
$ env/bin/python -m pip install gunicorn
(..)
Successfully installed gunicorn-20.0.4
$ ./env/bin/python -X dev -c 'from gunicorn.app.wsgiapp import run; run()' foobar:app
...) [2021-01-11 16:14:11 +0100] [32107] [ERROR] Exception in worker process
Traceback (most recent call last):
(...)
File "/home/vstinner/z/env/lib64/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/vstinner/z/env/lib64/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
(...)
ModuleNotFoundError: No module named 'foobar' [2021-01-11 16:14:11 +0100] [32107] [INFO] Worker exiting (pid: 32107) (...) You should report the issue to gunicorn: https://github.com/benoitc/gunicorn/issues |
That is not a segfault. The problem I am reporting is a segfault. It can be reproduced with uvicorn as follow: from lsm import LSM
db = LSM('db.sqlite')
async def app(scope, receive, send):
assert scope['type'] == 'http'
global db
for (index, (key, value)) in enumerate(db[b'\x00':b'\xFF']):
pass
db.close() Run the above program with: python -X dev -m uvicorn bobo:app Then in another console: curl http://localhost:8000/ Here is the output: $ python -X dev -m uvicorn bobo:app
INFO: Started server process [3580316]
INFO: Waiting for application startup.
INFO: ASGI 'lifespan' protocol appears unsupported.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Fatal Python error: Segmentation fault Current thread 0x00007fbb6e49b740 (most recent call first): |
I tried to reduce the program by replacing gunicorn / uvicorn dependency with threading.Thread and multiprocess.Pool without success. |
The problem is prolly in lsm-db. ref: coleifer/python-lsm-db#20 Sorry for the noise. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: