Finding reference-counting errors in Python/C programs with affine analysis

Siliang Li, Gang Tan

Research output: Chapter in Book/Report/Conference proceedingConference contribution

15 Scopus citations


Python is a popular programming language that uses reference counting to manage heap objects. Python also has a Foreign Function Interface (FFI) that allows Python extension modules to be written in native code such as C and C++. Native code, however, is outside Python's system of memory management; therefore extension programmers are responsible for making sure these objects are reference counted correctly. This is an error prone process when code becomes complex. In this paper, we propose Pungi, a system that statically checks whether Python objects' reference counts are adjusted correctly in Python/C interface code. Pungi transforms Python/C interface code into affine programs with respect to our proposed abstractions of reference counts. Our system performs static analysis on transformed affine programs and reports possible reference counting errors. Our prototype implementation found over 150 errors in a set of Python/C programs.

Original languageEnglish (US)
Title of host publicationECOOP 2014 - Object-Oriented Programming
Subtitle of host publication28th European Conference, Proceedings
PublisherSpringer Verlag
Number of pages25
ISBN (Print)9783662442012
StatePublished - 2014
Event28th European Conference on Object-Oriented Programming, ECOOP 2014 - Uppsala, Sweden
Duration: Jul 28 2014Aug 1 2014

Publication series

NameLecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Volume8586 LNCS
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349


Other28th European Conference on Object-Oriented Programming, ECOOP 2014

All Science Journal Classification (ASJC) codes

  • Theoretical Computer Science
  • Computer Science(all)


Dive into the research topics of 'Finding reference-counting errors in Python/C programs with affine analysis'. Together they form a unique fingerprint.

Cite this