Well, that didn't help much. Apparently, it dies freeing a variable:
#0 _PyWeakref_GetWeakrefCount (obj=<optimized out>) at Objects/weakrefobject.c:52
#1 _PyWeakref_GetWeakrefCount (obj=<optimized out>) at Objects/weakrefobject.c:42
#2 0x00007f8a9221b6d3 in PyObject_ClearWeakRefs (object=object@entry=0x7f8a91870d70) at Objects/weakrefobject.c:1039
#3 0x00007f8a921c9bb1 in subtype_dealloc (self=0x7f8a91870d70) at Objects/typeobject.c:2651
#4 0x00007f8a9219a218 in _Py_Dealloc (op=0x7f8a91870d70) at Objects/object.c:3072
#5 0x00007f8a922a8b8d in Py_DECREF_MORTAL (op=<optimized out>) at ./Include/internal/pycore_object.h:482
#6 PyStackRef_XCLOSE (ref=...) at ./Include/internal/pycore_stackref.h:660
#7 _PyFrame_ClearLocals (frame=frame@entry=0x7f8a920511a0) at Python/frame.c:101
#8 0x00007f8a922a8dfe in _PyFrame_ClearExceptCode (frame=frame@entry=0x7f8a920511a0) at Python/frame.c:126
#9 0x00007f8a92267b2b in clear_thread_frame (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a920511a0) at Python/ceval.c:1908
#10 _PyEval_FrameClearAndPop (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a920511a0) at Python/ceval.c:1932
#11 0x00007f8a922729af in _PyEval_EvalFrameDefault (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a920511a0, throwflag=1) at Python/generated_cases.c.h:10633
#12 0x00007f8a9227b9ee in _PyEval_EvalFrame (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=<optimized out>, throwflag=0) at ./Include/internal/pycore_ceval.h:121
#13 _PyEval_Vector (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, func=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>)
at Python/ceval.c:2083
#14 0x00007f8a92142876 in _PyObject_VectorcallTstate (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, callable=0x7f8a914b33d0, args=0x7ffed0368630, nargsf=1, kwnames=0x0)
at ./Include/internal/pycore_call.h:169
#15 PyObject_Vectorcall (callable=callable@entry=0x7f8a914b33d0, args=args@entry=0x7ffed0368630, nargsf=nargsf@entry=1, kwnames=kwnames@entry=0x0) at Objects/call.c:327
#16 0x00007f8a917d1292 in _CallPythonObject (st=0x7f8a91614870, mem=mem@entry=0x7ffed03688b0, restype=0x7f8a917ba190 <ffi_type_void>, setfunc=0x0, callable=<optimized out>,
converters=<optimized out>, flags=257, pArgs=<optimized out>) at ./Modules/_ctypes/callbacks.c:210
#17 0x00007f8a917d1429 in closure_fcn (cif=<optimized out>, resp=0x7ffed03688b0, args=0x7ffed0368720, userdata=0x7f8a914b3480) at ./Modules/_ctypes/callbacks.c:302
#18 0x00007f8a917b6195 in ffi_closure_unix64_inner () from /cs/re/2025-12-02-buildchain-perl5.42_pg15-debian12/lib/libffi.so.8
#19 0x00007f8a917b71e8 in ffi_closure_unix64 () from /cs/re/2025-12-02-buildchain-perl5.42_pg15-debian12/lib/libffi.so.8
#20 0x00007f8a9113b997 in isl_id_free () from .libs/libisl.so.23
#21 0x00007f8a917b7052 in ffi_call_unix64 () from /cs/re/2025-12-02-buildchain-perl5.42_pg15-debian12/lib/libffi.so.8
#22 0x00007f8a917b57ba in ffi_call_int () from /cs/re/2025-12-02-buildchain-perl5.42_pg15-debian12/lib/libffi.so.8
#23 0x00007f8a917b5e6d in ffi_call () from /cs/re/2025-12-02-buildchain-perl5.42_pg15-debian12/lib/libffi.so.8
#24 0x00007f8a917d33e3 in _call_function_pointer (st=0x7f8a91614870, flags=257, pProc=0x7f8a9113b920 <isl_id_free>, avalues=0x7ffed0368a70, atypes=<optimized out>, restype=<optimized out>,
resmem=0x7ffed0368a80, argcount=1, argtypecount=<optimized out>) at ./Modules/_ctypes/callproc.c:953
#25 _ctypes_callproc (st=0x7f8a91614870, pProc=0x7f8a9113b920 <isl_id_free>, argtuple=argtuple@entry=0x7f8a918ac980, flags=257, argtypes=argtypes@entry=0x7f8a90fb0180,
restype=restype@entry=0x55ed83ed5970, checker=0x0) at ./Modules/_ctypes/callproc.c:1319
#26 0x00007f8a917cda95 in PyCFuncPtr_call (op=<optimized out>, inargs=<optimized out>, kwds=0x0) at ./Modules/_ctypes/_ctypes.c:4679
#27 0x00007f8a9214261c in _PyObject_MakeTpCall (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, callable=0x7f8a90fa97f0, args=0x7ffed0368eb8, nargs=<optimized out>, keywords=0x0)
at Objects/call.c:242
#28 0x00007f8a9226e2dd in _PyEval_EvalFrameDefault (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a92051128, throwflag=1) at Python/generated_cases.c.h:1619
#29 0x00007f8a9227b9ee in _PyEval_EvalFrame (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=<optimized out>, throwflag=0) at ./Include/internal/pycore_ceval.h:121
#30 _PyEval_Vector (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, func=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>)
at Python/ceval.c:2083
#31 0x00007f8a921427e5 in _PyObject_VectorcallTstate (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, callable=0x7f8a90f99a60, args=0x7ffed0369058, nargsf=9223372036854775809, kwnames=0x0)
at ./Include/internal/pycore_call.h:169
#32 PyObject_CallOneArg (func=func@entry=0x7f8a90f99a60, arg=arg@entry=0x7f8a91862850) at Objects/call.c:395
#33 0x00007f8a921cd2c6 in call_unbound_noarg (unbound=<optimized out>, func=0x7f8a90f99a60, self=0x7f8a91862850) at Objects/typeobject.c:2901
#34 slot_tp_finalize (self=0x7f8a91862850) at Objects/typeobject.c:10517
#35 0x00007f8a9219961b in PyObject_CallFinalizer (self=0x7f8a91862850) at Objects/object.c:585
#36 0x00007f8a9219aaf5 in PyObject_CallFinalizerFromDealloc (self=self@entry=0x7f8a91862850) at Objects/object.c:603
#37 0x00007f8a921c973d in subtype_dealloc (self=0x7f8a91862850) at Objects/typeobject.c:2635
#38 0x00007f8a9219a218 in _Py_Dealloc (op=0x7f8a91862850) at Objects/object.c:3072
#39 0x00007f8a922a8b8d in Py_DECREF_MORTAL (op=<optimized out>) at ./Include/internal/pycore_object.h:482
#40 PyStackRef_XCLOSE (ref=...) at ./Include/internal/pycore_stackref.h:660
#41 _PyFrame_ClearLocals (frame=frame@entry=0x7f8a92051090) at Python/frame.c:101
--Type <RET> for more, q to quit, c to continue without paging--
#42 0x00007f8a922a8dfe in _PyFrame_ClearExceptCode (frame=frame@entry=0x7f8a92051090) at Python/frame.c:126
#43 0x00007f8a92267b2b in clear_thread_frame (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a92051090) at Python/ceval.c:1908
#44 _PyEval_FrameClearAndPop (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a92051090) at Python/ceval.c:1932
#45 0x00007f8a922729af in _PyEval_EvalFrameDefault (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=0x7f8a92051090, throwflag=1) at Python/generated_cases.c.h:10633
#46 0x00007f8a9227b9ee in _PyEval_EvalFrame (tstate=0x7f8a925e8e08 <_PyRuntime+315624>, frame=<optimized out>, throwflag=0) at ./Include/internal/pycore_ceval.h:121
#47 _PyEval_Vector (tstate=tstate@entry=0x7f8a925e8e08 <_PyRuntime+315624>, func=func@entry=0x7f8a9181b530, locals=locals@entry=0x7f8a91825a00, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:2083
#48 0x00007f8a9227bafb in PyEval_EvalCode (co=co@entry=0x55ed83e1efa0, globals=globals@entry=0x7f8a91825a00, locals=locals@entry=0x7f8a91825a00) at Python/ceval.c:975
#49 0x00007f8a922e10a3 in run_eval_code_obj (tstate=tstate@entry=0x7f8a925e8e08 <_PyRuntime+315624>, co=co@entry=0x55ed83e1efa0, globals=globals@entry=0x7f8a91825a00, locals=locals@entry=0x7f8a91825a00) at Python/pythonrun.c:1365
#50 0x00007f8a922e1408 in run_mod (mod=mod@entry=0x55ed83eac558, filename=filename@entry=0x7f8a9180ff90, globals=globals@entry=0x7f8a91825a00, locals=locals@entry=0x7f8a91825a00, flags=flags@entry=0x7ffed0369738, arena=arena@entry=0x7f8a91963e70, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1459
#51 0x00007f8a922e1764 in pyrun_file (fp=fp@entry=0x55ed83ccf720, filename=filename@entry=0x7f8a9180ff90, start=start@entry=257, globals=globals@entry=0x7f8a91825a00, locals=locals@entry=0x7f8a91825a00, closeit=closeit@entry=1, flags=0x7ffed0369738) at Python/pythonrun.c:1293
#52 0x00007f8a922e3671 in _PyRun_SimpleFileObject (fp=fp@entry=0x55ed83ccf720, filename=filename@entry=0x7f8a9180ff90, closeit=closeit@entry=1, flags=flags@entry=0x7ffed0369738) at Python/pythonrun.c:521
#53 0x00007f8a922e3cdc in _PyRun_AnyFileObject (fp=0x55ed83ccf720, filename=filename@entry=0x7f8a9180ff90, closeit=closeit@entry=1, flags=flags@entry=0x7ffed0369738) at Python/pythonrun.c:81
#54 0x00007f8a9230e0c9 in pymain_run_file_obj (program_name=0x7f8a91812640, filename=0x7f8a9180ff90, skip_source_first_line=0) at Modules/main.c:410
#55 pymain_run_file (config=0x7f8a925b3ed0 <_PyRuntime+98736>) at Modules/main.c:429
#56 pymain_run_python (exitcode=0x7ffed036972c) at Modules/main.c:694
#57 Py_RunMain () at Modules/main.c:775
#58 0x00007f8a9230e547 in pymain_main (args=args@entry=0x7ffed0369830) at Modules/main.c:805
#59 0x00007f8a9230e605 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:829
#60 0x00007f8a91db524a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#61 0x00007f8a91db5305 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#62 0x000055ed7555c081 in _start ()
The lines in Objects/weakrefobject.c are as follows:
47
48 LOCK_WEAKREFS(obj);
49 Py_ssize_t count = 0;
50 PyWeakReference *head = *GET_WEAKREFS_LISTPTR(obj);
51 while (head != NULL) {
52 ++count;
53 head = head->wr_next;
54 }
55 UNLOCK_WEAKREFS(obj);
56 return count;
and apparently, head is invalid:
(gdb) print head
$1 = (PyWeakReference *) 0x1021d
(gdb) print head->wr_next
Cannot access memory at address 0x1024d
I don't know if this helps you. I'll stick to Python 3.13 for now.