[Bug 2138881] [NEW] Python 3.12 livelock in asyncio module_traverse()

Douglas 2138881 at bugs.launchpad.net
Thu Jan 22 14:16:29 UTC 2026


Public bug reported:

Python 3.12 has a bug that can cause both livelocks and segfaults in
some asyncio garbage collection C code.

What I experienced today was the livelock symptom, but a team mate
experienced the segfault symptom in 2024, which lead to the issue being
fixed in upstream CPython.

Original CPython issue: https://github.com/python/cpython/issues/122695

Description of the livelock in that original issue:
https://github.com/python/cpython/issues/122695#issuecomment-2270732541

CPython 3.12 branch fix: https://github.com/python/cpython/pull/122859
CPython 3.13 branch fix: https://github.com/python/cpython/pull/122837


$ apt-cache policy python3    
python3:
  Installed: 3.12.3-0ubuntu2.1
  Candidate: 3.12.3-0ubuntu2.1
  Version table:
 *** 3.12.3-0ubuntu2.1 500
        500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu noble-security/main amd64 Packages
        100 /var/lib/dpkg/status
     3.12.3-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages

$ lsb_release -rd
No LSB modules are available.
Description:    Ubuntu 24.04.3 LTS
Release:        24.04


Todays's backtrace of the livelock (taken with gdb and the
python3.12-dbg package):

Thread 1 (Thread 0x701a05959080 (LWP 1032357) "python3"):
#0  0x000000000061d82f in _PyObject_IS_GC (obj=<_asyncio.FutureIter at remote 0x70199dce8f70>) at ../Include/object.h:968
#1  visit_decref (op=<_asyncio.FutureIter at remote 0x70199dce8f70>, parent=0x701a045d59e0) at ../Modules/gcmodule.c:465
#2  0x0000701a058269e0 in module_traverse (mod=<optimized out>, visit=0x61d820 <visit_decref>, arg=0x701a045d59e0) at ../Modules/_asynciomodule.c:3596
#3  0x00000000005823a6 in module_traverse (m=0x701a045d59e0, visit=0x61d820 <visit_decref>, arg=0x701a045d59e0) at ../Objects/moduleobject.c:874
#4  0x000000000061ca86 in subtract_refs (containers=0xb47ee0 <_PyRuntime+76576>) at ../Modules/gcmodule.c:491
#5  deduce_unreachable (unreachable=0x7ffdf55df770, base=0xb47ee0 <_PyRuntime+76576>) at ../Modules/gcmodule.c:1116
#6  gc_collect_main (tstate=tstate at entry=0xba5748 <_PyRuntime+459656>, generation=generation at entry=2, n_collected=n_collected at entry=0x7ffdf55df870, n_uncollectable=n_uncollectable at entry=0x7ffdf55df878, nofail=nofail at entry=0) at ../Modules/gcmodule.c:1242
#7  0x000000000061c471 in gc_collect_with_callback (generation=2, tstate=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:1426
#8  gc_collect_generations (tstate=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:1481
#9  _Py_RunGC (tstate=tstate at entry=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:2295

ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: python3 3.12.3-0ubuntu2.1
ProcVersionSignature: Ubuntu 6.8.0-90.91-generic 6.8.12
Uname: Linux 6.8.0-90-generic x86_64
ApportVersion: 2.28.1-0ubuntu3.8
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: KDE
Date: Thu Jan 22 14:03:11 2026
SourcePackage: python3-defaults
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: python3-defaults (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug noble

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python3-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/2138881

Title:
  Python 3.12 livelock in asyncio module_traverse()

Status in python3-defaults package in Ubuntu:
  New

Bug description:
  Python 3.12 has a bug that can cause both livelocks and segfaults in
  some asyncio garbage collection C code.

  What I experienced today was the livelock symptom, but a team mate
  experienced the segfault symptom in 2024, which lead to the issue
  being fixed in upstream CPython.

  Original CPython issue:
  https://github.com/python/cpython/issues/122695

  Description of the livelock in that original issue:
  https://github.com/python/cpython/issues/122695#issuecomment-2270732541

  CPython 3.12 branch fix: https://github.com/python/cpython/pull/122859
  CPython 3.13 branch fix: https://github.com/python/cpython/pull/122837

  
  $ apt-cache policy python3    
  python3:
    Installed: 3.12.3-0ubuntu2.1
    Candidate: 3.12.3-0ubuntu2.1
    Version table:
   *** 3.12.3-0ubuntu2.1 500
          500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
          500 http://archive.ubuntu.com/ubuntu noble-security/main amd64 Packages
          100 /var/lib/dpkg/status
       3.12.3-0ubuntu1 500
          500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages

  $ lsb_release -rd
  No LSB modules are available.
  Description:    Ubuntu 24.04.3 LTS
  Release:        24.04



  Todays's backtrace of the livelock (taken with gdb and the
  python3.12-dbg package):

  Thread 1 (Thread 0x701a05959080 (LWP 1032357) "python3"):
  #0  0x000000000061d82f in _PyObject_IS_GC (obj=<_asyncio.FutureIter at remote 0x70199dce8f70>) at ../Include/object.h:968
  #1  visit_decref (op=<_asyncio.FutureIter at remote 0x70199dce8f70>, parent=0x701a045d59e0) at ../Modules/gcmodule.c:465
  #2  0x0000701a058269e0 in module_traverse (mod=<optimized out>, visit=0x61d820 <visit_decref>, arg=0x701a045d59e0) at ../Modules/_asynciomodule.c:3596
  #3  0x00000000005823a6 in module_traverse (m=0x701a045d59e0, visit=0x61d820 <visit_decref>, arg=0x701a045d59e0) at ../Objects/moduleobject.c:874
  #4  0x000000000061ca86 in subtract_refs (containers=0xb47ee0 <_PyRuntime+76576>) at ../Modules/gcmodule.c:491
  #5  deduce_unreachable (unreachable=0x7ffdf55df770, base=0xb47ee0 <_PyRuntime+76576>) at ../Modules/gcmodule.c:1116
  #6  gc_collect_main (tstate=tstate at entry=0xba5748 <_PyRuntime+459656>, generation=generation at entry=2, n_collected=n_collected at entry=0x7ffdf55df870, n_uncollectable=n_uncollectable at entry=0x7ffdf55df878, nofail=nofail at entry=0) at ../Modules/gcmodule.c:1242
  #7  0x000000000061c471 in gc_collect_with_callback (generation=2, tstate=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:1426
  #8  gc_collect_generations (tstate=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:1481
  #9  _Py_RunGC (tstate=tstate at entry=0xba5748 <_PyRuntime+459656>) at ../Modules/gcmodule.c:2295

  ProblemType: Bug
  DistroRelease: Ubuntu 24.04
  Package: python3 3.12.3-0ubuntu2.1
  ProcVersionSignature: Ubuntu 6.8.0-90.91-generic 6.8.12
  Uname: Linux 6.8.0-90-generic x86_64
  ApportVersion: 2.28.1-0ubuntu3.8
  Architecture: amd64
  CasperMD5CheckResult: unknown
  CurrentDesktop: KDE
  Date: Thu Jan 22 14:03:11 2026
  SourcePackage: python3-defaults
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/2138881/+subscriptions




More information about the foundations-bugs mailing list