Features/StaticAnalysisOfCPythonExtensions

From FedoraProject

Comments and Explanations The page source contains comments providing guidance to fill out each section. They are invisible when viewing this page. To read it, choose the "edit" link.Copy the source to a new page before making changes! DO NOT EDIT THIS TEMPLATE FOR YOUR FEATURE.

Set a Page WatchMake sure you click watch on your new page so that you are notified of changes to it by others, including the Feature Wrangler

All sections of this template are required for review by FESCo. If any sections are empty it will not be reviewed

Static Analysis of CPython Extensions

Summary

I'm working on a static analysis tool that can detect common mistakes made in Python extension modules written in C. We'll run it on all such code in Fedora, fixing any problems we find, and send the patches to the appropriate upstream projects.

Owner

Current status

Detailed Description

Python makes it relatively easy to write wrapper code for C and C++ libraries, acting as a "glue" from which programs can be created.

Unfortunately, there are various mistakes that are commonly made in such wrapper code, and these mistakes can lead to /usr/bin/python leaking memory, segfaulting. There are other mistakes that only manifest as bugs when run on less common CPU architectures.

I'm working on static analysis code for C, to detect common errors in C extension modules for Python. The plan is to integrate this with Fedora's packaging, so that all C extension modules packaged for Python 2 and Python 3 can be guaranteed free of such errors (by adding hooks to the python-devel and python3-devel). We can also send fixes for this code as needed to upstream projects, when it reports problems. (Naturally this assumes a good signal:noise ratio from the tool).

Benefit to Fedora

Fedora is already a great environment for doing Python development - having a good-quality static analysis tool integrated into Fedora's build system for python extension modules will make Fedora even more compelling for Python developers.

The presence of the tool should also make it easier to fix certain awkward bugs, and make it easier to support secondary CPU architectures.

Scope

This involves:

writing the tool

tuning it to achieve a good signal:noise ratio:

testing it on a large number of different extension modules

analyzing the issues that it reports; fixing bugs in the

itegrating it into the python 2 and python 3 build of Fedora RPMs (python-devel and python3-devel)