[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: Python 3.11 and QObject.destroyed signals: _PyThreadState_PopFrame: Assertion `tstate->datastack
From: Florian Bruhin <me () the-compiler ! org>
Date: 2022-07-13 10:39:33
Message-ID: 20220713103933.2ehm2ngvrunmuqad () aragog
[Download RAW message or body]
On Fri, Jul 08, 2022 at 05:30:27PM +0200, Florian Bruhin wrote:
> when testing my application with the current Python 3.11 beta, I've
> noticed a bug which seems to be triggered somehow by something PyQt
> does: https://github.com/python/cpython/issues/93252
>
> This is the most trivial reproducer I could find:
>
> from PyQt5.QtCore import QObject
>
> def run():
> obj = QObject()
> for _ in range(202):
> obj.destroyed.connect(lambda: None)
>
> run()
>
> Which crashes CPython with:
>
> python: Python/pystate.c:2201: _PyThreadState_PopFrame: Assertion \
> `tstate->datastack_top >= base' failed.
FWIW, we ended up finding a much simpler reproducer, not involving PyQt:
def f():
pass
for _ in range(203):
try:
f(None)
except:
pass
Thus this happened when a stack frame can't be built up - Python never
cleaned it properly in that case. It's been fixed in 3.11.0b4:
https://github.com/python/cpython/pull/94708/commits/be41a146c6595200107cb3ece97809cb506dffba
I don't quite understand why/how the connection to QObject.destroyed
exhibits the same behavior, but in any case, the patch fixes it.
Florian
--
me@the-compiler.org | https://www.qutebrowser.org
https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic