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

[Tests] GUI tests on Mac randomly fails with Fatal Python error: Segmentation fault #6564

Closed
drew2a opened this issue Nov 18, 2021 · 4 comments

Comments

@drew2a
Copy link
Contributor

drew2a commented Nov 18, 2021

The full log: https://jenkins-ci.tribler.org/job/GH_Tribler_PR_Tests/job/PR_GUI_macOS/3519/console

Fatal Python error: Segmentation fault

Current thread 0x00000001086b95c0 (most recent call first):
<no Python frame>
/var/folders/9h/rc1ccw796x7dsjy2_nxjrxw40000gn/T/jenkins7492326316941345297.sh: line 11: 20855 Segmentation fault: 11  pytest src/tribler-gui/tribler_gui --guitests -p no:randomly -v --cov=tribler_gui --cov-report=xml
Build step 'Execute shell' marked build as failure

Error occurred during in #6563

@drew2a drew2a changed the title [Tests] GUI tests on windows randomly fails with Fatal Python error: Segmentation fault [Tests] GUI tests on Mac randomly fails with Fatal Python error: Segmentation fault Nov 18, 2021
@devos50
Copy link
Contributor

devos50 commented Nov 19, 2021

I did see this one earlier on my machine but it's very hard to reproduce and seems to happen randomly. A screenshot of the crash details as reported by MacOS:

Schermafbeelding 2021-11-19 om 09 57 22

So this seems to happen during some cleanup procedures when exiting the Python interpreter. Searching for sip_api_visit_wrappers brings me to this issue, reporting a similar crash. Some more information:

When the Python interpreter leaves a scope (for example when it returns from a function) it will potentially garbage collect all objects local to that scope. The order in which it is done is, in effect, random. Theoretically this can cause problems because it may mean that the C++ destructors of any wrapped Qt instances are called in an order that Qt isn’t expecting and may result in a crash. However, in practice, this is only likely to be a problem when the application is terminating.

As a way of mitigating this possiblity PyQt5 ensures that the C++ destructors of any QObject instances owned by Python are invoked before the destructor of any QCoreApplication instance is invoked. Note however that the order in which the QObject destructors are invoked is still random.

Since the stack trace does not provide any further useful information, this one can be pretty nasty to debug. It could be that we are mis-managing a particular QObject but given the sheer amount of objects in our application, we probably need to attach a debugger to the crashing process to determine which object is causing the crash.

Updating the version of Python/Qt/sip might also helpful.

@kozlovsky
Copy link
Contributor

Good finding about the sip!

Seems related to:
https://gitanswer.com/pyqtgraph-segmentation-fault-during-garbage-collection-python-826318977
mantidproject/mantidimaging#875
mantidproject/mantidimaging#894

If I understand correctly, it is possible that the error happened not when the Python interpreter exits, but when pyqtgraph closes the ImaveView object. Then we probably can avoid segfault by changing the way we work with pyqtgraph.

@drew2a
Copy link
Contributor Author

drew2a commented Jan 5, 2022

@drew2a
Copy link
Contributor Author

drew2a commented Jun 29, 2022

Didn't see any segmentation fault errors for a long time.

@drew2a drew2a closed this as completed Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants