#1108039 An object referenced only through it's own __dict__ can get collected too early

Package:
python3.13
Source:
python3.13
Description:
Interactive high-level object-oriented language (version 3.13)
Submitter:
Thomas Goirand
Date:
2026-03-05 17:41:06 UTC
Severity:
normal
Tags:
#1108039#5
Date:
2025-06-19 14:49:29 UTC
From:
To:
Hi,

Python 3.13 is affected by this bug, referenced upstream:
https://github.com/python/cpython/issues/130327

The result is, in some cases, an object is garbage collected even if there
is a reference to it in a program.

The consequence for OpenStack Nova (ie: compute) is that spawning a VM
simply does not work. Here's the Nova bug entry:
https://bugs.launchpad.net/nova/+bug/2103413

This happens when Nova (OpenStack compute) tries to get credential from
Keystone (OpenStack auth) to talk to Neutron (OpenStack network), in order
to create a network port. It fails to get such credentials, as the object
keystoneauth1.session.SessionClient is garbaged collected due to the bug in
CPython.

This is only a single identified instance of the bug in Nova, though it is
very probable that we have this kind of troubles with many other Python code
in Trixie.

Stefano identified (bisected) the issue to this commit:
https://github.com/python/cpython/commit/c32dc47aca6e8fac152699bc613e015c44ccdba9

and a possible patch could be this one:
https://github.com/python/cpython/pull/130469/files

This patch hasn't been tested (yet).

I hope my bug report is detailed enough. To me, this is a grave RC bug that
must be fixed before the Trixie release. I'm in fact, *VERY* happy that we
have finally discovered what was going on in Nova and OpenStack, I was
desperating to find out. It looks like I'll only need to upload the latest
Eventlet to fix the remaining troubles when this CPython bug if fixed (more
about this later on in another bug entry...).

Cheers,

Thomas Goirand (zigo)

#1108039#10
Date:
2025-06-19 15:56:38 UTC
From:
To:
Control: found -1 3.13.0~b3-1
Control: forwarded -1 https://github.com/python/cpython/issues/130327
Control: affects python3-nova

I'll have a look at that and see if I can see why it stalled.

Stefano

#1108039#21
Date:
2025-06-25 12:46:53 UTC
From:
To:
A possible fix is also here:

https://patch-diff.githubusercontent.com/raw/python/cpython/pull/135728.diff

I'll attempt to test this (not sure I'll have enough time though).

Cheers,

Thomas Goirand (zigo)

#1108039#26
Date:
2025-06-26 07:54:50 UTC
From:
To:
FYI, I attempted the backport. The patch of course doesn't apply, as the
gc.c has changed quite a bit. But it's not only about applying cleaning:
some of the logic in the GC has changed, such as the stats object
addition, which makes the backport impossible if not understanding the
insights of the Python GC. At this time, this is above my skills and it
would take me too much time to understand how the GC works to be able to
do a working backport. Hopefully, upstream will work on this.

If someone needs my rebased patch attempt, let me know.

Cheers,

Thomas Goirand (zigo)