[Python-Dev] Coverity Scan (original) (raw)

Christian Heimes christian at python.org
Fri Jul 26 16:29:59 CEST 2013


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 */ }

Christian



More information about the Python-Dev mailing list