On Fri, Jul 26, 2013 at 7:29 AM, Christian Heimes <christ...@python.org>wrote:
> Am 26.07.2013 14:56, schrieb Eli Bendersky: > > Just a quick question - is there a chance to convince Coverity to detect > > Python refcounting leaks in C API code :-) ? This could be useful not > > only for Python but for extensions too. As it stands now, Coverity's > > leak detection is Python must be pretty weak because almost everything > > is done via PyObject refcounts. > > Coverity is able to detect some cases of refcount leaks. I don't know if > the software is able to keep track of all reference counts. But it > understands missing Py_DECREF() in error branches. > > For example: > > PyObject *n = PyLong_FromLong(0); > PyObject *u = PyUnicode_FromString("example"); > > if (u == NULL) { > return NULL; > /* Coverity detects that 'n' leaks memory */ > } > Interesting. I was thinking of something more general though. Especially if we can mark function arguments and return values as stealing references / creating new ones / etc, many many common refcount bugs can be detected with static analysis. This is definitely research-y, probably too much for our current stage of relationship with Coverity :) Eli
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com