Static Prediction of Runtime Errors by Learning to Execute Programs with External Resource Descriptions

David Bieber, Rishab Goel, Daniel Zheng, Hugo Larochelle, Daniel Tarlow
3/7/2022
cs.LGcs.PL

Official code: google-research/runtime-error-prediction (25 stars, Python, Apache-2.0, last commit 2022-11-18).

Abstract

The execution behavior of a program often depends on external resources, such as program inputs or file contents, and so cannot be run in isolation. Nevertheless, software developers benefit from fast iteration loops where automated tools identify errors as early as possible, even before programs can be compiled and run.

Show full abstract

This presents an interesting machine learning challenge: can we predict runtime errors in a "static" setting, where program execution is not possible? Here, we introduce a real-world dataset and task for predicting runtime errors, which we show is difficult for generic models like Transformers. We approach this task by developing an interpreter-inspired architecture with an inductive bias towards mimicking program executions, which models exception handling and "learns to execute" descriptions of the contents of external resources. Surprisingly, we show that the model can also predict the location of the error, despite being trained only on labels indicating the presence/absence and kind of error. In total, we present a practical and difficult-yet-approachable challenge problem related to learning program execution and we demonstrate promising new capabilities of interpreter-inspired machine learning models for code.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

This is the repository for the paper Static Prediction of Runtime Errors by Learning to Execute Programs with External Resource Descriptions, and for the Python Runtime Errors (PRE) dataset.

256Python, ShellMay 13, 20214 years agoApache-2.0

Similar Papers

Cite this paper

@article{bieber2022static,
  title  = {Static Prediction of Runtime Errors by Learning to Execute Programs with External Resource Descriptions},
  author = {David Bieber and Rishab Goel and Daniel Zheng and Hugo Larochelle and Daniel Tarlow},
  year   = {2022},
  eprint = {2203.03771},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.03771}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.03771.svg)](https://codeofpaper.com/paper/2203.03771)

Discussion