Segmentation fault for scoped references with multiple QNetworkReply objects
Phil Thompson
phil at riverbankcomputing.com
Tue Aug 13 11:59:25 BST 2024
On 12/08/2024 17:46, Maurizio Berti wrote:
> Il giorno lun 12 ago 2024 alle ore 11:02 Phil Thompson <
> phil at riverbankcomputing.com> ha scritto:
>
>> First off, I can't reproduce the problem - even if I double the number
>>
>
>
>> of URLs to 200.
>>
>
> That's odd.
> I just tried on another VM (lubuntu 24.04 on live cd) and I can still
> reproduce both with the builtin PyQt5 (Qt 5.15.13, PyQt 5.15.10) and
> PyQt6
> (6.7.1) installed through pip.
> In some cases it never even get beyond 10 finished replies, and this
> also
> seems to be related by the number of current requests: if I reduce the
> timer interval to 10-20ms in some cases it just segfaults at the very
> first
> finished reply (I can see it if I connect to the "doSomething" function
> before any other).
> I suppose then that it's also related to the number of currently
> active/queued requests, so maybe in my case it fails almost always due
> to
> the relatively slow network speed I have (also decreased by the VM
> bottleneck)
> Can you try by decreasing the timeout interval and slowing down the
> response time?
> I made some reliable tests with https://httpbin.org/delay/1 (one second
> delay), PyQt6 gets rarely more than 20 results before fault, Qt5 often
> crashes on the very first one.
I can get crashes with PyQt6 but not PyQt5 (this is on macOS).
> However looking at the reply object using sip.dump() shows it has no
>> parent wrapped object whereas the docs for QNetworkReply::manager()
>> state that the manager is the reply's parent. Adding a /Transfer/
>> annotation to QNetworkManager::get() fixes this - but I have no idea
>> if
>> this has any effect on your test case.
>>
>
> That would be interesting to explore, but I wouldn't be able to
> build/test
> it on my own.
> How come that sip.dump() doesn't show the parent, while I'm able to
> print
> out both manager() and parent()?
PyQt keeps a similar hierarchy of Python objects to Qt's. sip.dump() is
reporting PyQt's.
> In the meantime, I decided to create a persistent list for the replies,
> and
> then remove each one when finished/destroyed.
> It seems to work so far, both in the provided MRE (including the stress
> cases above) and in my actual program.
>
> Thanks,
> MaurizioB
Adding the /Transfer/s to PyQt6 seems to resolve the crashes. I've added
them to PyQt5 as well.
I'm surprised this hasn't come up before.
Thanks,
Phil
More information about the PyQt
mailing list