Qt 5.13: Segfault on exit with Windows + QtWebEngine

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Qt 5.13: Segfault on exit with Windows + QtWebEngine

Florian Bruhin
With a quite minimal QtWebEngine example like this:

    from PyQt5.QtWebEngineWidgets import QWebEngineProfile
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QTimer

    qapp = QApplication([])
    p = QWebEngineProfile()
    QTimer.singleShot(500, qapp.quit)
    qapp.exec_()

I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine 5.13.0
on Windows 10.

When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work fine.

Unfortunately I haven't been able to get a reliable stacktrace. Here are some
examples of the stacks I got: https://paste.the-compiler.org/view/5774da86
I don't think they really make sense though.

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Phil Thompson-5
On 13/07/2019 16:43, Florian Bruhin wrote:

> With a quite minimal QtWebEngine example like this:
>
>     from PyQt5.QtWebEngineWidgets import QWebEngineProfile
>     from PyQt5.QtWidgets import QApplication
>     from PyQt5.QtCore import QTimer
>
>     qapp = QApplication([])
>     p = QWebEngineProfile()
>     QTimer.singleShot(500, qapp.quit)
>     qapp.exec_()
>
> I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine
> 5.13.0
> on Windows 10.
>
> When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work
> fine.
>
> Unfortunately I haven't been able to get a reliable stacktrace. Here
> are some
> examples of the stacks I got:
> https://paste.the-compiler.org/view/5774da86
> I don't think they really make sense though.

I can't reproduce this - although I am using Python v3.7.0.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Florian Bruhin
On Wed, Jul 17, 2019 at 11:54:10AM +0100, Phil Thompson wrote:

> On 13/07/2019 16:43, Florian Bruhin wrote:
> > With a quite minimal QtWebEngine example like this:
> >
> >     from PyQt5.QtWebEngineWidgets import QWebEngineProfile
> >     from PyQt5.QtWidgets import QApplication
> >     from PyQt5.QtCore import QTimer
> >
> >     qapp = QApplication([])
> >     p = QWebEngineProfile()
> >     QTimer.singleShot(500, qapp.quit)
> >     qapp.exec_()
> >
> > I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine
> > 5.13.0
> > on Windows 10.
> >
> > When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work
> > fine.
> >
> > Unfortunately I haven't been able to get a reliable stacktrace. Here are
> > some
> > examples of the stacks I got:
> > https://paste.the-compiler.org/view/5774da86
> > I don't think they really make sense though.
>
> I can't reproduce this - although I am using Python v3.7.0.
I can reproduce it with Python 3.7.0 as well (both 32 and 64-bit).

Note that I don't get a "Python.exe has stopped" window, but "echo $?" shows
False in Powershell.

Similarly, running it from Python:

  subprocess.run([sys.executable, 'segv.py'], check=True)

Gives me:

  subprocess.CalledProcessError: Command '['...\\python.exe', 'segv.py']' returned non-zero exit status 3221225477.

Where 3221225477 is 0xC0000005, i.e. an access violation.

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Phil Thompson-5
On 17/07/2019 12:48, Florian Bruhin wrote:

> On Wed, Jul 17, 2019 at 11:54:10AM +0100, Phil Thompson wrote:
>> On 13/07/2019 16:43, Florian Bruhin wrote:
>> > With a quite minimal QtWebEngine example like this:
>> >
>> >     from PyQt5.QtWebEngineWidgets import QWebEngineProfile
>> >     from PyQt5.QtWidgets import QApplication
>> >     from PyQt5.QtCore import QTimer
>> >
>> >     qapp = QApplication([])
>> >     p = QWebEngineProfile()
>> >     QTimer.singleShot(500, qapp.quit)
>> >     qapp.exec_()
>> >
>> > I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine
>> > 5.13.0
>> > on Windows 10.
>> >
>> > When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work
>> > fine.
>> >
>> > Unfortunately I haven't been able to get a reliable stacktrace. Here are
>> > some
>> > examples of the stacks I got:
>> > https://paste.the-compiler.org/view/5774da86
>> > I don't think they really make sense though.
>>
>> I can't reproduce this - although I am using Python v3.7.0.
>
> I can reproduce it with Python 3.7.0 as well (both 32 and 64-bit).
>
> Note that I don't get a "Python.exe has stopped" window, but "echo $?"
> shows
> False in Powershell.
>
> Similarly, running it from Python:
>
>   subprocess.run([sys.executable, 'segv.py'], check=True)
>
> Gives me:
>
>   subprocess.CalledProcessError: Command '['...\\python.exe',
> 'segv.py']' returned non-zero exit status 3221225477.
>
> Where 3221225477 is 0xC0000005, i.e. an access violation.

I can reproduce that. However if I build the latest PyQt against Qt
v5.12.4 the problem goes away, which suggests a Qt problem. I can only
suggest playing with things to try and get things destroyed in a
different order, then I might be able to add a workaround.

Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Florian Bruhin
On Wed, Jul 17, 2019 at 04:58:22PM +0100, Phil Thompson wrote:

> On 17/07/2019 12:48, Florian Bruhin wrote:
> > On Wed, Jul 17, 2019 at 11:54:10AM +0100, Phil Thompson wrote:
> > > On 13/07/2019 16:43, Florian Bruhin wrote:
> > > > With a quite minimal QtWebEngine example like this:
> > > >
> > > >     from PyQt5.QtWebEngineWidgets import QWebEngineProfile
> > > >     from PyQt5.QtWidgets import QApplication
> > > >     from PyQt5.QtCore import QTimer
> > > >
> > > >     qapp = QApplication([])
> > > >     p = QWebEngineProfile()
> > > >     QTimer.singleShot(500, qapp.quit)
> > > >     qapp.exec_()
> > > >
> > > > I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine
> > > > 5.13.0
> > > > on Windows 10.
> > > >
> > > > When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work
> > > > fine.
> > > >
> > > > Unfortunately I haven't been able to get a reliable stacktrace. Here are
> > > > some
> > > > examples of the stacks I got:
> > > > https://paste.the-compiler.org/view/5774da86
> > > > I don't think they really make sense though.
> > >
> > > I can't reproduce this - although I am using Python v3.7.0.
> >
> > I can reproduce it with Python 3.7.0 as well (both 32 and 64-bit).
> >
> > Note that I don't get a "Python.exe has stopped" window, but "echo $?"
> > shows
> > False in Powershell.
> >
> > Similarly, running it from Python:
> >
> >   subprocess.run([sys.executable, 'segv.py'], check=True)
> >
> > Gives me:
> >
> >   subprocess.CalledProcessError: Command '['...\\python.exe',
> > 'segv.py']' returned non-zero exit status 3221225477.
> >
> > Where 3221225477 is 0xC0000005, i.e. an access violation.
>
> I can reproduce that. However if I build the latest PyQt against Qt v5.12.4
> the problem goes away, which suggests a Qt problem. I can only suggest
> playing with things to try and get things destroyed in a different order,
> then I might be able to add a workaround.
Using qapp as a context manager seems to fix it.
Putting everything into a run() function (without "global qapp") and calling
that also does.

In other words, if the QApplication is destroyed *before* whatever QtWebEngine
initializes internally it seems to not segfault.

That seems the exact opposite of what's recommended here though:
https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Florian Bruhin
On Wed, Jul 17, 2019 at 06:10:24PM +0200, Florian Bruhin wrote:

> On Wed, Jul 17, 2019 at 04:58:22PM +0100, Phil Thompson wrote:
> > On 17/07/2019 12:48, Florian Bruhin wrote:
> > > On Wed, Jul 17, 2019 at 11:54:10AM +0100, Phil Thompson wrote:
> > > > On 13/07/2019 16:43, Florian Bruhin wrote:
> > > > > With a quite minimal QtWebEngine example like this:
> > > > >
> > > > >     from PyQt5.QtWebEngineWidgets import QWebEngineProfile
> > > > >     from PyQt5.QtWidgets import QApplication
> > > > >     from PyQt5.QtCore import QTimer
> > > > >
> > > > >     qapp = QApplication([])
> > > > >     p = QWebEngineProfile()
> > > > >     QTimer.singleShot(500, qapp.quit)
> > > > >     qapp.exec_()
> > > > >
> > > > > I get a segfault on exit with Python 3.7.4 and PyQt5/PyQtWebEngine
> > > > > 5.13.0
> > > > > on Windows 10.
> > > > >
> > > > > When I downgrade to PyQt5 5.12.3 and PyQtWebEngine 5.12.1 things work
> > > > > fine.
> > > > >
> > > > > Unfortunately I haven't been able to get a reliable stacktrace. Here are
> > > > > some
> > > > > examples of the stacks I got:
> > > > > https://paste.the-compiler.org/view/5774da86
> > > > > I don't think they really make sense though.
> > > >
> > > > I can't reproduce this - although I am using Python v3.7.0.
> > >
> > > I can reproduce it with Python 3.7.0 as well (both 32 and 64-bit).
> > >
> > > Note that I don't get a "Python.exe has stopped" window, but "echo $?"
> > > shows
> > > False in Powershell.
> > >
> > > Similarly, running it from Python:
> > >
> > >   subprocess.run([sys.executable, 'segv.py'], check=True)
> > >
> > > Gives me:
> > >
> > >   subprocess.CalledProcessError: Command '['...\\python.exe',
> > > 'segv.py']' returned non-zero exit status 3221225477.
> > >
> > > Where 3221225477 is 0xC0000005, i.e. an access violation.
> >
> > I can reproduce that. However if I build the latest PyQt against Qt v5.12.4
> > the problem goes away, which suggests a Qt problem. I can only suggest
> > playing with things to try and get things destroyed in a different order,
> > then I might be able to add a workaround.
>
> Using qapp as a context manager seems to fix it.
> Putting everything into a run() function (without "global qapp") and calling
> that also does.
>
> In other words, if the QApplication is destroyed *before* whatever QtWebEngine
> initializes internally it seems to not segfault.
>
> That seems the exact opposite of what's recommended here though:
> https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit
FWIW I also can't reproduce the issue with PySide2 5.13.0 (with a simple
s/PyQt5/PySide2/ in the original reproducer).

(Sorry for the follow-up - only occurred to me to try that after I already sent
my original mail)

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

Florian Bruhin
In reply to this post by Florian Bruhin
Hi Phil,

I assume you accidentally didn't Cc the list, so I added it back.

On Sun, Jul 21, 2019 at 06:10:58PM +0100, Phil Thompson wrote:
> In tonight's SIP and PyQt5 snapshots I have re-written how QObjects are
> cleaned up when an application exits.
>
> Are you able to test these changes (from the source code)? There is no hurry
> as I don't plan on making new releases until Qt 5.13.1.
>
> I'm a bit nervous about the changes as they could simply replace one set of
> problems with another.

The good news: This seems to fix a long-standing problem I have with
QtWebEngine cookies not being saved on exit:
https://github.com/qutebrowser/qutebrowser/issues/2263

The bad news: You seem to be right. I only did a couple of quick tests on
Linux, and so far I got:

- An abort() due to an error in PyQtSlotProxy::unislot():
  https://paste.the-compiler.org/view/8a17300b
  (I don't have the error message I'm afraid)

- An X error and assertion failure inside Chromium:
  https://paste.the-compiler.org/view/b9219e33

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
BPL
Reply | Threaded
Open this post in threaded view
|

Re: Qt 5.13: Segfault on exit with Windows + QtWebEngine

BPL
Florian,

Is this thread related to the other one I'd opened few days ago called "QtWebEngine crashing with certain app attributes"?

Asking as that thread hadn't been replied at all but this seems to be related (it also crashes on exit)... btw, I'd opened that thread here in the pyqt mailing list
but I wanted to test it first on c++. Unfortunately for some reason qtcreator wouldn't find qtwebengine (which I installed with
the maintenance tool on top of an existing qt installation):


QT += gui webenginewidgets

CONFIG += c++11 console
CONFIG -= app_bundle

DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

main.cpp:

#include <QApplication>
#include <QtOpenGL/QtOpenGL>
#include <QtWidgets/QDockWidget>
#include <QtWidgets/QPlainTextEdit>

int main(int argc, char *argv[]) {
    bool MAKE_IT_CRASH = true;

    if (MAKE_IT_CRASH) {
        QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
    }

    QApplication a(argc, argv);

    QWebEngineView *view = new QWebEngineView(parent);
    view->load(QUrl("http://qt-project.org/"));
    view->show();

    return a.exec();
}

Probably this is a different issue but the fact you've said "you didn't Cc the list" made me wonder if this could
be related somehow

On Tue, Jul 23, 2019 at 10:20 AM Florian Bruhin <[hidden email]> wrote:
Hi Phil,

I assume you accidentally didn't Cc the list, so I added it back.

On Sun, Jul 21, 2019 at 06:10:58PM +0100, Phil Thompson wrote:
> In tonight's SIP and PyQt5 snapshots I have re-written how QObjects are
> cleaned up when an application exits.
>
> Are you able to test these changes (from the source code)? There is no hurry
> as I don't plan on making new releases until Qt 5.13.1.
>
> I'm a bit nervous about the changes as they could simply replace one set of
> problems with another.

The good news: This seems to fix a long-standing problem I have with
QtWebEngine cookies not being saved on exit:
https://github.com/qutebrowser/qutebrowser/issues/2263

The bad news: You seem to be right. I only did a couple of quick tests on
Linux, and so far I got:

- An abort() due to an error in PyQtSlotProxy::unislot():
  https://paste.the-compiler.org/view/8a17300b
  (I don't have the error message I'm afraid)

- An X error and assertion failure inside Chromium:
  https://paste.the-compiler.org/view/b9219e33

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt