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 segfault on PyQt 5.12-13 due to wrong QApplication initializations #4934

Closed
markotoplak opened this issue Aug 7, 2020 · 4 comments · Fixed by #4941
Closed

Tests segfault on PyQt 5.12-13 due to wrong QApplication initializations #4934

markotoplak opened this issue Aug 7, 2020 · 4 comments · Fixed by #4941
Labels
bug A bug confirmed by the core team

Comments

@markotoplak
Copy link
Member

markotoplak commented Aug 7, 2020

EDIT: This seems to happen everywhere on PyQt 5.12.

On MacOS with pip-installed Orange I get segfaults when running tests on master. Running Orange or individual widgets seems to work well. Python 3.7, PyQt5==5.12.3, PyQtWebEngine==5.12.

python -m unittest Orange.widgets.visualize.tests.test_owscatterplot
Segmentation fault: 11

The segfault is immediate. The segfault started occuring after #4828 was merged.

git checkout c11ec5efada3f52315b3939c66e8896a0d73f3ec  # Merge pull request #4828 from VesnaT/customize_plots
python -m unittest Orange.widgets.visualize.tests.test_owscatterplot
Segmentation fault: 11

If I checkout the master from before that PR was merged (git checkout 2655592eee43145cfca4ff87073046941908a749), tests pass.

The stack trace shows this:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   QtGui                         	0x000000011a479e18 QOpenGLContext::isValid() const + 8
1   QtWebEngineCore               	0x000000011c7c3a52 0x11c748000 + 506450
2   QtWebEngineCore               	0x000000011c7c2405 0x11c748000 + 500741
3   QtWebEngineWidgets            	0x000000011c4a8d4a 0x11c4a1000 + 32074
4   QtWebEngineWidgets            	0x000000011c4ab5e0 QWebEnginePage::QWebEnginePage(QObject*) + 48
5   QtWebEngineWidgets            	0x000000011c4b81d2 QWebEngineView::page() const + 50
6   QtWebEngineWidgets.so         	0x000000011c46808b meth_QWebEngineView_page(_object*, _object*) + 75
7   org.python.python             	0x0000000105882747 _PyMethodDef_RawFastCallKeywords + 235
...
@markotoplak markotoplak added the bug report Bug is reported by user, not yet confirmed by the core team label Aug 7, 2020
@markotoplak
Copy link
Member Author

The same happens to me on Ubuntu 18.04, Python 3.6, PyQt5==5.12.3, PyQtWebEngine==5.12.1.

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffb7d17c04 in QOpenGLContext::isValid() const () from /home/marko/venvorange/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5

And on Ubuntu 18.04, Python 3.7, PyQt5==5.12, PyQtWebEngine==5.12:

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffc4aed970 in QOpenGLContext::isValid() const () from /home/marko/venv37/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5

I then updated this environment to PyQt5==5.14.0, PyQtWebEngine==5.14.0 and tests started working well. When I downgraded 5.12, I again get segfaults.

@markotoplak
Copy link
Member Author

markotoplak commented Aug 7, 2020

I also tried other pyqt versions on my Mac, and I get segfaults with PyQt 5.12 and PyQt 5.13. PyQt 5.14 does not segfault.

@markotoplak markotoplak changed the title Tests on current master segfault after PR #4828 Tests on current master segfault after PR #4828 on PyQt 5.12 Aug 7, 2020
@markotoplak
Copy link
Member Author

@VesnaT also confirmed this bug on her computer. This needs to be fixed before release. We need to be compatible with pyqt 5.12, because that is the newest version that is available on conda-forge.

@markotoplak markotoplak added bug A bug confirmed by the core team and removed bug report Bug is reported by user, not yet confirmed by the core team labels Aug 7, 2020
@markotoplak
Copy link
Member Author

These segfaults are caused by constructing a new QApplication for getting default fonts in Orange.widgets.visualize.utils.customizableplot.Updater. To verify, comment appropriate font settings in Updater.

The problem is that default font settings are set on import, before an actual QApplication was instantiated (Orange's GuiTest tries to make only one). For example, just a script importing the following file would print "A".

class A:
    print("A")
    def __init__(self):
        print("B")

In customizableplot.Updater there are, in place of print("A"), calls to functions that create new QApplications. I do not think we can keep these in the same place. @VesnaT, @janezd?

@markotoplak markotoplak changed the title Tests on current master segfault after PR #4828 on PyQt 5.12 Tests segfault on PyQt 5.12 due to wrong QApplication initializations Aug 11, 2020
@markotoplak markotoplak changed the title Tests segfault on PyQt 5.12 due to wrong QApplication initializations Tests segfault on PyQt 5.12-13 due to wrong QApplication initializations Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug confirmed by the core team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant