Skip to content
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

Segmentation fault in versions >=3.1.1 #2875

Closed
jcozar87 opened this issue Oct 27, 2017 · 4 comments
Closed

Segmentation fault in versions >=3.1.1 #2875

jcozar87 opened this issue Oct 27, 2017 · 4 comments
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@jcozar87
Copy link

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:

  • appdirs (1.4.3)
  • flake8 (3.5.0)
  • mccabe (0.6.1)
  • packaging (16.8)
  • pip (9.0.1)
  • py (1.4.34)
  • pycodestyle (2.3.1)
  • pyflakes (1.6.0)
  • pyparsing (2.2.0)
  • pytest (3.1.1)
  • setuptools (34.3.3)
  • six (1.11.0)
  • virtualenv (15.1.0)

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.

@The-Compiler
Copy link
Member

Can you install pytest-faulthandler and maybe run with -vs? That should give you some useful output.

@jcozar87
Copy link
Author

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.

@nicoddemus nicoddemus added the type: question general question, might be closed after 2 weeks of inactivity label Oct 27, 2017
@cleemesser
Copy link

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)

@nicoddemus
Copy link
Member

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.

ptrstn added a commit to ptrstn/TkDQMDoctor that referenced this issue Aug 15, 2018
As suggested in pytest-dev/pytest#2875 the
segmentation faults should not happen anymore when pytest-faulthandler
is installed

Travis-CI occasionally gives following error message:
1893 Segmentation fault  (core dumped) PYTHONWARNINGS=all pytest --cov=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants