Segfault while installing modules: scikit-learn, hiredis, numpy, redis, scipy, tqdm>=4.29.1
See original GitHub issueEnvironment
- pip version: pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
- Python version: Python 3.5.3
- OS: Debian GNU/Linux 9 (stretch)
Description segfault while installing modules
Expected behavior no segfault
How to Reproduce I wrote a Reproducer here: https://github.com/pippy360/python_reproducer_for_segfault
To reproduce just install the following setup file:
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='lets cause a segfault',
packages=find_packages(),
python_requires='>=3.5',
install_requires=[
'scikit-learn',
'hiredis',
'numpy',
'redis',
'scipy',
'tqdm>=4.29.1',
]
)
Output
user@instance-3:~/python_reproducer_for_segfault$ pip3 install .
Processing /home/user/python_reproducer_for_segfault
Collecting hiredis (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/51/df/d2a08fb767247c0acea66255908e60cdeb4cd13cf71d42a1e2ca5803a1f8/hiredis-1.0.0-cp35-cp35m-manylinux1_x86_64.whl (49kB)
100% |ββββββββββββββββββββββββββββββββ| 51kB 1.7MB/s
Collecting numpy (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/ad/15/690c13ae714e156491392cdbdbf41b485d23c285aa698239a67f7cfc9e0a/numpy-1.16.1-cp35-cp35m-manylinux1_x86_64.whl (17.2MB)
100% |ββββββββββββββββββββββββββββββββ| 17.2MB 82kB/s
Collecting redis (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/f1/19/a0282b77c23f9f9dbcc6480787a60807c78a45947593a02dbf026636c90d/redis-3.1.0-py2.py3-none-any.whl (63kB)
100% |ββββββββββββββββββββββββββββββββ| 71kB 11.3MB/s
Collecting scikit-learn (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/18/d9/bea927c86bf78d583d517f24cbc87606cb333bfb3a5c99cb85b547305f0f/scikit_learn-0.20.2-cp35-cp35m-manylinux1_x86_64.whl (5.3MB)
100% |ββββββββββββββββββββββββββββββββ| 5.3MB 279kB/s
Collecting scipy (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/ab/19/c0ad5b9183ef97030edd6297d1726525ff2c369a09fbb6ea52a1e616ffd6/scipy-1.2.0-cp35-cp35m-manylinux1_x86_64.whl (26.5MB)
100% |ββββββββββββββββββββββββββββββββ| 26.5MB 48kB/s
Collecting tqdm>=4.29.1 (from lets-cause-a-segfault==0.0.0)
Downloading https://files.pythonhosted.org/packages/76/4c/103a4d3415dafc1ddfe6a6624333971756e2d3dd8c6dc0f520152855f040/tqdm-4.30.0-py2.py3-none-any.whl (47kB)
100% |ββββββββββββββββββββββββββββββββ| 51kB 10.9MB/s
Installing collected packages: hiredis, numpy, redis, scipy, scikit-learn, tqdm, lets-cause-a-segfault
Running setup.py install for lets-cause-a-segfault ... done
Successfully installed hiredis-1.0.0 lets-cause-a-segfault-0.0.0 numpy-1.16.1 redis-3.1.0 scikit-learn-0.20.2 scipy-1.2.0 tqdm-4.30.0
user@instance-3:~/python_reproducer_for_segfault$ ^C
user@instance-3:~/python_reproducer_for_segfault$ pip3 install .
Processing /home/user/python_reproducer_for_segfault
Collecting hiredis (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/51/df/d2a08fb767247c0acea66255908e60cdeb4cd13cf71d42a1e2ca5803a1f8/hiredis-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
Collecting numpy (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/ad/15/690c13ae714e156491392cdbdbf41b485d23c285aa698239a67f7cfc9e0a/numpy-1.16.1-cp35-cp35m-manylinux1_x86_64.whl
Collecting redis (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/f1/19/a0282b77c23f9f9dbcc6480787a60807c78a45947593a02dbf026636c90d/redis-3.1.0-py2.py3-none-any.whl
Collecting scikit-learn (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/18/d9/bea927c86bf78d583d517f24cbc87606cb333bfb3a5c99cb85b547305f0f/scikit_learn-0.20.2-cp35-cp35m-manylinux1_x86_64.whl
Collecting scipy (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/ab/19/c0ad5b9183ef97030edd6297d1726525ff2c369a09fbb6ea52a1e616ffd6/scipy-1.2.0-cp35-cp35m-manylinux1_x86_64.whl
Collecting tqdm>=4.29.1 (from lets-cause-a-segfault==0.0.0)
Using cached https://files.pythonhosted.org/packages/76/4c/103a4d3415dafc1ddfe6a6624333971756e2d3dd8c6dc0f520152855f040/tqdm-4.30.0-py2.py3-none-any.whl
Installing collected packages: hiredis, numpy, redis, scipy, scikit-learn, tqdm, lets-cause-a-segfault
Running setup.py install for lets-cause-a-segfault ... done
Successfully installed hiredis-1.0.0 lets-cause-a-segfault-0.0.0 numpy-1.16.1 redis-3.1.0 scikit-learn-0.20.2 scipy-1.2.0 tqdm-4.30.0
Segmentation fault
user@instance-3:~/python_reproducer_for_segfault$
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to reproduce this.
The segfault occurs at Python interpreter shutdown, when trying to clean up the
Reader
member of thehiredis
module - the type associated with this object is null, so attempting to dereference it causes a segfault.backtrace
If we look at the
op
indict_traverse
we see that itβs the module dict for hiredisAnd inspection of the
Reader
member shows thatob_type
is null, but this is dereferenced invisit_decref
as part ofPyObject_IS_GC
, leading to segfault.In pip 9.0.1 (the version installed by python3-pip in Debian 9) we were using CacheControl 0.11.7.
In CacheControl 0.11.7,
cachecontrol.caches
was importingredis
.redis
importshiredis
.For some reason importing
hiredis
before the processing we do to installhiredis
causes the condition that leads to the segfault mentioned above. This aligns with the observation that the crash happens on the second and subsequent installs.Iβve simplified this a bit by doing the following:
hiredis
alone - still segfaultshiredis
from a pre-downloaded wheel - still segfaultshiredis
instead ofredis
- still segfaultshiredis.cpython-35m-x86_64-linux-gnu.so
tohiredis.so
, so that the file that gets written on install is different than the one that was imported - does not segfaultI havenβt been able to reproduce this with the latest pip yet, even explicitly importing hiredis in
pip
itself and running with--user --ignore-installed
in order to get similar behavior to 9.0.1.I have responded to your email with the ssh details for a vm