arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1805.11683cs.SEcs.PL
收藏

DeepBugs:一种基于名称的错误检测学习方法

DeepBugs: A Learning Approach to Name-based Bug Detection

Michael Pradel, Koushik Sen

摘要:

源代码中的自然语言元素,例如,变量和函数的名称传达了有用的信息。然而,大多数现有的错误检测工具忽略了这些信息,因此错过了一些类别的错误。现有的几种基于名称的错误检测方法在语法级别上对名称进行推理,并依赖于手动设计和调优的算法来检测错误。本文介绍了DeepBugs,一种基于名称的错误检测的学习方法,它基于语义表示来推理名称,并自动学习错误检测器,而不是手动编写它们。我们制定了一个二进制分类问题的缺陷检测和训练分类器,区分正确的不正确的代码。为了解决有效学习bug检测器需要正确和不正确代码的例子的挑战,我们通过简单的代码转换从现有的代码语料库中创建可能不正确的代码例子。从我们的工作中学到的一个新的见解是,从人工播种的bug中学习可以产生bug检测器,这些bug检测器可以有效地发现真实代码中的bug。我们实现我们的想法到一个框架,学习为基础的和基于名称的错误检测。在框架之上构建的三个错误检测器检测意外交换的函数参数,不正确的二元运算符和二元运算中不正确的操作数。将该方法应用于150,000个JavaScript文件的语料库,产生具有高准确性(89%至95%之间)的错误检测器,非常有效(每个分析文件不到20毫秒),并在真实代码中揭示102个编程错误(68%的真阳性率)。

英文摘要:

Natural language elements in source code, e.g., the names of variables and functions, convey useful information. However, most existing bug detection tools ignore this information and therefore miss some classes of bugs. The few existing name-based bug detection approaches reason about names on a syntactic level and rely on manually designed and tuned algorithms to detect bugs. This paper presents DeepBugs, a learning approach to name-based bug detection, which reasons about names based on a semantic representation and which automatically learns bug detectors instead of manually writing them. We formulate bug detection as a binary classification problem and train a classifier that distinguishes correct from incorrect code. To address the challenge that effectively learning a bug detector requires examples of both correct and incorrect code, we create likely incorrect code examples from an existing corpus of code through simple code transformations. A novel insight learned from our work is that learning from artificially seeded bugs yields bug detectors that are effective at finding bugs in real-world code. We implement our idea into a framework for learning-based and name-based bug detection. Three bug detectors built on top of the framework detect accidentally swapped function arguments, incorrect binary operators, and incorrect operands in binary operations. Applying the approach to a corpus of 150,000 JavaScript files yields bug detectors that have a high accuracy (between 89% and 95%), are very efficient (less than 20 milliseconds per analyzed file), and reveal 102 programming mistakes (with 68% true positive rate) in real-world code.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑