In the GitHub Actions ubuntu-latest runner, I am getting a segmentation fault while running some of my Python tests using Pytest.
Run xvfb-run pytest on the GitHub Actions CI, below with gdb debugging:
(Gaphor) runner@fv-az76:~/work/gaphor/gaphor$ gdb -ex r --args python -m pytest GNU gdb (Ubuntu 8.2-0ubuntu1~18.04) 8.2 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> Starting program: /home/runner/work/gaphor/gaphor/.venv/bin/python -m pytest [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [Detaching after fork from child process 7738] [Detaching after fork from child process 7740] [Detaching after fork from child process 7741] [Detaching after fork from child process 7742] ============================================= test session starts ============================================== platform linux -- Python 3.8.0, pytest-5.3.0, py-1.8.0, pluggy-0.13.1 rootdir: /home/runner/work/gaphor/gaphor, inifile: pytest.ini, testpaths: gaphor, tests, docs plugins: xvfb-1.2.0, cov-2.8.1 collecting ... [New Thread 0x7fffe1493700 (LWP 7755)] [New Thread 0x7fffe0c92700 (LWP 7756)] [Detaching after fork from child process 7757] collecting 224 items Thread 1 "python" received signal SIGSEGV, Segmentation fault. PyModule_GetState (m=0x0) at Objects/moduleobject.c:565 565 Objects/moduleobject.c: No such file or directory.
The issue is isolated to some of the doctests and a couple of test modules that call the pydoc module. As you can see above the seg fault occurs while collecting the tests. I can get the tests to pass once I remove doctest and the other test modules.
I do not get any errors when running the same tests using windows-latest or macos-latest. I do not get the errors locally in Ubuntu, or when using Ubuntu in Azure Pipelines.
I have tried both Python 3.7 and 3.8, I get the segmentation faults for both cases. The errors happen with multiple versions of Pytest, including 4.x and 5.x releases.
Because the error is pointing to an issue with Objects/moduleobject.c missing, I think this must be an issue with the Python installed on the ubuntu runners. If anyone has any other ideas on how to further isolate root cause, I would be glad to perform those actions as well.
Are you using setup-python action to specify which version of python should be used? https://github.com/marketplace/actions/setup-python-environment
This is really entriguing since it's working on Azure Pipelines (the same images are used by GitHub Actions so there should be no regressions).
If you use Python without the setup-python action then it will default to system python on Ubuntu. If the error still persists with the setup-python action perhaps there is some bug in the action itself, only differences that I can think of.
Hi @konradpabjan, thanks for the response. Yes I am using the setup-python action.
Should I submit an Issue to the setup-python action repo?
No need for an issue in setup-python (unless we determine that it's the source of the issue, but at this point I don't suspect it's the root cause).
Do you have a public repo to possibly repo this? At this point the only thing that I can think of is to try out the scenario on GitHub Actions and on Azure Pipelines to try to spot a difference. The images and tools on the runners are same, and the setup-python action is nearly identical to the use-python task on Azure Pipelines.
It is a public repository for an app called Gaphor. The Azure Pipelines configuration that we were using is posted. As well as the build workflow using GitHub Action. If you want to see the errors yourself, you need to renable the Console entry point in the pyproject.toml and renable the doctests in the pytest.ini.