I am using pytest in a project running in a docker container. The docker image that I am using is the python:3.6-slip version from resin, resin/raspberrypi3-python:3.6-slim.
This is the pip3 list:
If I run pytest -v --duration=0, I get the Segmentation fault (core dumped) exception. But if I use the 3.1.0 version of pytest it works correctly. Moreover, if I run the docker container using the interactive mode (options -ti) it works fine even for versions >=3.1.1.
The code I am testing uses asyncio, running in ARM architecture (raspberry pi 3).
Sorry for not reporting more information about the bug, but I cannot debug in interactive mode, so I am not sure about the best way to obtain more information about it.
Can you install pytest-faulthandler and maybe run with -vs? That should give you some useful output.
First of all, thank you for your fast response.
I tried what you said. Finally, I discovered that just installing pytest-faulthandler 1.3.1, the segmentation fault does not happen.
In addition, I have to say that I am using the module logging and the StreamHandler (might be it is useful to discover the problem).
Thank you in advance.
I started having a similar problem in multiple conda environments. Even empty tests seem to trigger the fault. It turned out that it was importing matplotlib for some reason and that has recently started causing segfaults with the anaconda5 serices. This was fixed for me by changing matplotlib. It was not clear to me why matplotlib was being imported.
-C
platform linux -- Python 3.6.4, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/clee/code/eegml/eeg-hdfstorage, inifile:
plugins: faulthandler-1.5.0
collecting 0 items Fatal Python error: Segmentation fault
Current thread 0x00007fdf826b9700 (most recent call first):
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 922 in create_module
File "<frozen importlib._bootstrap>", line 571 in module_from_spec
File "<frozen importlib._bootstrap>", line 658 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1023 in _handle_fromlist
File "/home/clee/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 140 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/home/clee/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 54 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/home/clee/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/home/clee/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 19 in <module>collect_one_node
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 529 in genitems
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 388 in _perform_collect
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 351 in perform_collect
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 154 in pytest_collection
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180 in _multicall
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 216 in <lambda>
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 222 in _hookexec
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 617 in __call__
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 144 in _main
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 107 in wrap_session
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/main.py", line 138 in pytest_cmdline_main
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180 in _multicall
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 216 in <lambda>
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 222 in _hookexec
File "/home/clee/anaconda3/lib/python3.6/site-packages/pluggy/__init__.py", line 617 in __call__
File "/home/clee/anaconda3/lib/python3.6/site-packages/_pytest/config.py", line 61 in main
File "/home/clee/anaconda3/bin/py.test", line 11 in <module>
Segmentation fault (core dumped)
I'm closing this for now, I think people have found suitable workarounds. In general, seg faults are not caused by pytest itself by some other module (with C extensions), so the hard part is diagnose which one.
Most helpful comment
Can you install pytest-faulthandler and maybe run with
-vs? That should give you some useful output.