一句话:首个对 JavaScript 中字符串相关缺陷的根因、后果与修复特征的系统性实证研究。
字符串在程序中承担正则匹配、反射元素名、嵌入他语言代码、拼接输出等多种角色,但开发者在此类代码上的常见错误此前缺乏系统认识,导致重复犯错且工具支持薄弱。本文首次对字符串相关缺陷的根因、后果等性质开展实证研究,系统分析了 JavaScript 中来自多个项目的 204 个字符串缺陷。研究发现:许多错误源于一组反复出现的根因模式,如错误的字符串字面量与正则表达式;后果多样,包括输出错误或预期行为的静默丢失;修复往往只需改动一行,且修复素材多存在于周边代码;这类缺陷遍布应用各部分,包括核心组件;而现有静态分析器几乎无法检出。研究结论可帮助开发者避免常见错误,并指导工具构建者发现与修复此类缺陷。
Strings play many roles in programming because they often contain complex and semantically rich information. For example, programmers use strings to filter inputs via regular expression matching, to express the names of program elements accessed through some form of reflection, to embed code written in another formal language, and to assemble textual output produced by a program. The omnipresence of strings leads to a wide range of mistakes that developers may make, yet little is currently known about these mistakes. The lack of knowledge about string-related bugs leads to developers repeating the same mistakes again and again, and to poor support for finding and fixing such bugs. This paper presents the first empirical study of the root causes, consequences, and other properties of string-related bugs. We systematically study 204 string-related bugs in a diverse set of projects written in JavaScript, a language where strings play a particularly important role. Our findings include (i) that many string-related mistakes are caused by a recurring set of root cause patterns, such as incorrect string literals and regular expressions, (ii) that string-related bugs have a diverse set of consequences, including incorrect output or silent omission of expected behavior, (iii) that fixing string-related bugs often requires changing just a single line, with many of the required repair ingredients available in the surrounding code, (iv) that string-related bugs occur across all parts of applications, including the core components, and (v) that almost none of these bugs are detected by existing static analyzers. Our findings not only show the importance and prevalence of string-related bugs, but they help developers to avoid common mistakes and tool builders to tackle the challenge of finding and fixing string-related bugs.
DOI 原文 ·
@inproceedings{paperbot5897,
title = {No strings attached},
author = {Aryaz Eghbali and Michael Pradel},
booktitle = {ASE},
year = {2020},
doi = {10.1145/3324884.3416576}
}