[issue36880] Returning None from a callback with restype py_object decrements None's refcount too much

anthony shaw report at bugs.python.org
Sat May 11 02:27:02 EDT 2019


anthony shaw <anthonyshaw at apache.org> added the comment:

Full trace for reference:

(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff5984f2c6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff59904bf1 libsystem_pthread.dylib`pthread_kill + 284
    frame #2: 0x00007fff597b96a6 libsystem_c.dylib`abort + 127
    frame #3: 0x0000000100236c14 python.exe`fatal_error(prefix=0x0000000000000000, msg="_PyObject_AssertFailed", status=-1) at pylifecycle.c:2128:9
    frame #4: 0x0000000100236a5e python.exe`Py_FatalError(msg="_PyObject_AssertFailed") at pylifecycle.c:2138:5
    frame #5: 0x00000001000b49f4 python.exe`_PyObject_AssertFailed(obj=0x000000010038a2c0, expr=0x0000000000000000, msg="object has negative ref count", file="Objects/typeobject.c", line=3187, function="_Py_NegativeRefcount") at object.c:2163:5
    frame #6: 0x00000001000b4a44 python.exe`_Py_NegativeRefcount(filename="Objects/typeobject.c", lineno=3187, op=0x000000010038a2c0) at object.c:208:5
    frame #7: 0x00000001000d2bad python.exe`_Py_DECREF(filename="Objects/typeobject.c", lineno=3187, op=0x000000010038a2c0) at object.h:468:13
    frame #8: 0x00000001000d5889 python.exe`_PyType_Lookup(type=0x00000001003e4ad0, name=0x000000010064bba0) at typeobject.c:3187:9
    frame #9: 0x00000001000b731f python.exe`_PyObject_GenericGetAttrWithDict(obj=0x0000000100645dd0, name=0x000000010064bba0, dict=0x0000000000000000, suppress=0) at object.c:1221:13
    frame #10: 0x00000001000b7243 python.exe`PyObject_GenericGetAttr(obj=0x0000000100645dd0, name=0x000000010064bba0) at object.c:1309:12
    frame #11: 0x00000001000b69a8 python.exe`PyObject_GetAttr(v=0x0000000100645dd0, name=0x000000010064bba0) at object.c:916:16
    frame #12: 0x0000000100301599 python.exe`textiowrapper_closed_get(self=0x00000001006aba50, context=0x0000000000000000) at textio.c:3015:12
    frame #13: 0x000000010004eedf python.exe`getset_get(descr=0x000000010122f210, obj=0x00000001006aba50, type=0x00000001003e7280) at descrobject.c:158:16
    frame #14: 0x00000001000b738c python.exe`_PyObject_GenericGetAttrWithDict(obj=0x00000001006aba50, name=0x00000001016f00a8, dict=0x0000000000000000, suppress=0) at object.c:1228:19
    frame #15: 0x00000001000b7243 python.exe`PyObject_GenericGetAttr(obj=0x00000001006aba50, name=0x00000001016f00a8) at object.c:1309:12
    frame #16: 0x00000001000b69a8 python.exe`PyObject_GetAttr(v=0x00000001006aba50, name=0x00000001016f00a8) at object.c:916:16
    frame #17: 0x00000001000b68e4 python.exe`PyObject_GetAttrString(v=0x00000001006aba50, name="closed") at object.c:821:11
    frame #18: 0x00000001002399cc python.exe`file_is_closed(fobj=0x00000001006aba50) at pylifecycle.c:1074:21
    frame #19: 0x0000000100235f64 python.exe`flush_std_files at pylifecycle.c:1094:45
    frame #20: 0x0000000100236bfd python.exe`fatal_error(prefix=0x0000000000000000, msg="deallocating None", status=-1) at pylifecycle.c:2116:9
    frame #21: 0x0000000100236a5e python.exe`Py_FatalError(msg="deallocating None") at pylifecycle.c:2138:5
    frame #22: 0x00000001000b8318 python.exe`none_dealloc(ignore=0x000000010038a2c0) at object.c:1551:5
    frame #23: 0x00000001000ba6ba python.exe`_Py_Dealloc(op=0x000000010038a2c0) at object.c:2178:5
    frame #24: 0x00000001001dec2b python.exe`_Py_DECREF(filename="Python/ceval.c", lineno=1200, op=0x000000010038a2c0) at object.h:473:9
    frame #25: 0x00000001001cd444 python.exe`_PyEval_EvalFrameDefault(f=0x000000010130b860, throwflag=0) at ceval.c:1200:13
    frame #26: 0x00000001001cc277 python.exe`PyEval_EvalFrameEx(f=0x000000010130b860, throwflag=0) at ceval.c:625:12
    frame #27: 0x00000001001e3347 python.exe`_PyEval_EvalCodeWithName(_co=0x000000010146b880, globals=0x0000000101246e50, locals=0x0000000101246e50, args=0x0000000000000000, argcount=0, kwnames=0x0000000000000000, kwargs=0x0000000000000000, kwcount=0, kwstep=2, defs=0x0000000000000000, defcount=0, kwdefs=0x0000000000000000, closure=0x0000000000000000, name=0x0000000000000000, qualname=0x0000000000000000) at ceval.c:4036:14
    frame #28: 0x00000001001cc1f0 python.exe`PyEval_EvalCodeEx(_co=0x000000010146b880, globals=0x0000000101246e50, locals=0x0000000101246e50, args=0x0000000000000000, argcount=0, kws=0x0000000000000000, kwcount=0, defs=0x0000000000000000, defcount=0, kwdefs=0x0000000000000000, closure=0x0000000000000000) at ceval.c:4065:12
    frame #29: 0x00000001001cc04e python.exe`PyEval_EvalCode(co=0x000000010146b880, globals=0x0000000101246e50, locals=0x0000000101246e50) at ceval.c:602:12
    frame #30: 0x0000000100249f55 python.exe`run_eval_code_obj(co=0x000000010146b880, globals=0x0000000101246e50, locals=0x0000000101246e50) at pythonrun.c:1047:9
    frame #31: 0x00000001002483f7 python.exe`run_mod(mod=0x0000000102017438, filename=0x0000000101495d30, globals=0x0000000101246e50, locals=0x0000000101246e50, flags=0x00007ffeefbff690, arena=0x00000001012e2520) at pythonrun.c:1063:9
    frame #32: 0x00000001002478b5 python.exe`PyRun_FileExFlags(fp=0x00007fff8c715030, filename_str="/Users/anthonyshaw/cpython/test_gc_ctypes.py", start=257, globals=0x0000000101246e50, locals=0x0000000101246e50, closeit=1, flags=0x00007ffeefbff690) at pythonrun.c:994:11
    frame #33: 0x0000000100246c91 python.exe`PyRun_SimpleFileExFlags(fp=0x00007fff8c715030, filename="/Users/anthonyshaw/cpython/test_gc_ctypes.py", closeit=1, flags=0x00007ffeefbff690) at pythonrun.c:429:13
    frame #34: 0x00000001002467bc python.exe`PyRun_AnyFileExFlags(fp=0x00007fff8c715030, filename="/Users/anthonyshaw/cpython/test_gc_ctypes.py", closeit=1, flags=0x00007ffeefbff690) at pythonrun.c:85:16
    frame #35: 0x0000000100277095 python.exe`pymain_run_file(config=0x0000000101800ca8, cf=0x00007ffeefbff690) at main.c:346:15
    frame #36: 0x000000010027641d python.exe`pymain_run_python(exitcode=0x00007ffeefbff75c) at main.c:511:21
    frame #37: 0x00000001002760cc python.exe`_Py_RunMain at main.c:583:24
    frame #38: 0x0000000100276612 python.exe`pymain_main(args=0x00007ffeefbff7c8) at main.c:612:12
    frame #39: 0x0000000100276655 python.exe`_Py_UnixMain(argc=2, argv=0x00007ffeefbff830) at main.c:636:12
    frame #40: 0x0000000100000d82 python.exe`main(argc=2, argv=0x00007ffeefbff830) at python.c:16:12
    frame #41: 0x00007fff597143d5 libdyld.dylib`start + 1

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36880>
_______________________________________


More information about the Python-bugs-list mailing list