[PyQt] Segfaults when disconnecting signal from QWebFrame::contentsSizeChanged

Florian Bruhin me at the-compiler.org
Tue Oct 28 20:41:02 GMT 2014


Hi,

with Qt 5.3.1 and PyQt 5.3.2 I got some segfault reports from users
because of a weird issue. Unfortunately I've been unsuccessful in
contacting them and never could reproduce it myself, so I can't
provide a C level backtrace, but maybe someone has an idea.

Basically, this is what I'm doing, in a QWebView:

- Connecting QWebFrame::contentsSizeChanged to a certain slot,
  decorated with @pyqtSlot('QSize')
- Dispatching mouse events to click on links, possibly moving away
  from the current page.
- Disconnecting the slot from the frame.

You can see the full code at [1].

On the last step I get a segfault, i.e. the Python stacktrace points
to line 160 in [1]:

    f.contentsSizeChanged.disconnect(self.on_contents_size_changed)

As said, this is almost unreproducable...

What I could imagine happening is this:

- There's some race condition between Qt deleting the QWebFrame, and
  me disconnecting my signal after I did the fake "click".
- For some reason, PyQt didn't detect the object isn't alive anymore,
  and I got a segfault instead of a RuntimeError.

Any idea what could be going on? I guess I'll experiment with using
weakref instead and see if that fixes the issue... Unfortunately my
way of telling it works is "I didn't get crash reports for some weeks"
so far, so I can only guess...

Florian

[1] https://github.com/The-Compiler/qutebrowser/blob/c2daadf0bde8c008b8f3b534c3ff12f29a834d15/qutebrowser/browser/hints.py

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141028/eae8c8c6/attachment.sig>


More information about the PyQt mailing list