PythonMonkey
PythonMonkey copied to clipboard
Fix remaining memory bugs
The CI sometimes fail on main even after we released the "stable" PythonMonkey v1.0.
After all pytests are done, the program segfaults during the Python interpreter finalization.
============================= 678 passed in 23.59s =============================
/Users/runner/work/_temp/cab3e84e-a831-4a41-9c31-79102f1651a5.sh: line 7: 5781 Segmentation fault: 11 (core dumped) poetry run python -m pytest tests/python
Debugged using a debug build of Python
* thread #1, name = 'python', stop reason = signal SIGSEGV: address not mapped to object
* frame #0: 0x0000ffff97f6acf8 libpython3.11.so.1.0`PyObject_GC_Del [inlined] gc_list_remove(node=0x0000ffff9124d2b0) at gcmodule.c:269:5
frame #1: 0x0000ffff97f6acf8 libpython3.11.so.1.0`PyObject_GC_Del(op=0x0000ffff9124d2c0) at gcmodule.c:2350:9
frame #2: 0x0000ffff97f02d34 libpython3.11.so.1.0`maybe_freelist_clear(interp=0x0000ffff982706d0, fini=0) at tupleobject.c:1251:13
frame #3: 0x0000ffff9800cee0 libpython3.11.so.1.0`gc_collect_main [inlined] clear_freelists(interp=0x0000ffff982706d0) at gcmodule.c:1037:5
frame #4: 0x0000ffff9800ced8 libpython3.11.so.1.0`gc_collect_main(tstate=0x0000ffff9828aa50, generation=2, n_collected=0x0000000000000000, n_uncollectable=0x0000000000000000, nofail=1) at gcmodule.c:1313:9
frame #5: 0x0000ffff9800d5a4 libpython3.11.so.1.0`_PyGC_CollectNoFail(tstate=<unavailable>) at gcmodule.c:2110:9
frame #6: 0x0000ffff97ffd2a0 libpython3.11.so.1.0`Py_FinalizeEx at pylifecycle.c:1833:5
frame #7: 0x0000ffff9800b788 libpython3.11.so.1.0`Py_RunMain at main.c:682:9
frame #8: 0x0000ffff9800b468 libpython3.11.so.1.0`Py_BytesMain(argc=<unavailable>, argv=<unavailable>) at main.c:734:12
frame #9: 0x0000ffff97bb73fc libc.so.6`___lldb_unnamed_symbol2962 + 108
frame #10: 0x0000ffff97bb74cc libc.so.6`__libc_start_main + 152
frame #11: 0x0000aaaade3e08b0 python3.11`_start + 48