◐ Shell
clean mode source ↗

Message 164257 - Python tracker

I believe I have found the root-cause for this issue.   

It  is occurring due to the use of the garbage collector in another “memMonitor” thread (we run it periodically to get stats on objects, track mem leaks, etc).  Since _pysqlite_fetch_one_row() releases the GIL before calling PyTuple_SetItem(),  if the  memMonitor is scheduled to run and, say, calls gc.get_objects(), it increments the refcount on all tracked objects (via append_objects()->PyList_Append()->app1()->PY_INCREF()).    I have stack traces to confirm.   This seems to rule out the use of gc methods (such as get_objects(), get_referrers/referents()) in multi-threaded programs or have them handle SystemError arising from such usage.  Agree?