Patches item #1517947, was opened at 2006-07-05 23:43 Message generated for change (Comment added) made by bcannon You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517947&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Rene Dudfield (illume) Assigned to: Nobody/Anonymous (nobody) Summary: assert for NULL in Py_INCREF Py_DECREF Initial Comment: Since Py_INCREF and Py_DECREF should not be able to take NULLs they should do an assert check for this. This would have caught at least one bug earlier in cPickle.loads() http://sourceforge.net/tracker/index.php?func=detail&aid=1512695&group_id=5470&atid=105470 It will also help other extension module authors find this error in their code more easily. Include/object.h #define Py_INCREF(op) ( \ (assert((op) != NULL)) , \ _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ (op)->ob_refcnt++) #define Py_DECREF(op) \ if ((assert((op) != NULL)) , _Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ --(op)->ob_refcnt != 0) \ _Py_CHECK_REFCNT(op) \ else \ _Py_Dealloc((PyObject *)(op)) ---------------------------------------------------------------------- >Comment By: Brett Cannon (bcannon) Date: 2006-07-06 17:21 Message: Logged In: YES user_id=357491 I don't think that the cPickle bug would have been any sooner. The segfault happens just as early as an assertion would have since both going to access bad memory. Regardless, the adding of the assert() in Py_DECREF might warrant using ``while{} do(0)`` to simplify the code. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1517947&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
