一句话:JAttack 框架利用带 DSL 洞的模板 Java 程序随机生成测试输入,发现 JIT 编译器六个关键缺陷。
编译器测试,尤其是即时编译(JIT)编译器的测试,难以生成能触发复杂优化的程序。本文提出 JAttack,一个基于模板的编译器测试框架:开发者用宿主语言 Java 编写模板程序,其中包含由领域特定语言(DSL)描述的洞;每个洞构造扩展抽象语法树(eAST)中的一个节点,定义该洞的搜索空间(一组表达式和值)。JAttack 通过执行模板并随机从搜索空间中选择表达式与值填充洞来生成测试程序,同时引入若干优化以降低生成开销。作者用 JAttack 测试 Java JIT 编译器,共发现并被 Oracle 开发者确认六个关键缺陷,其中四个此前未知,包括两个未知的 CVE。
We present JAttack, a framework that enables template-based testing for compilers. Using JAttack, a developer writes a template program that describes a set of programs to be generated and given as test inputs to a compiler. Such a framework enables developers to incorporate their domain knowledge on testing compilers, giving a basic program structure that allows for exploring complex programs that can trigger sophisticated compiler optimizations. A developer writes a template program in the host language (Java) that contains holes to be filled by JAttack. Each hole, written using a domain-specific language, constructs a node within an extended abstract syntax tree (eAST). An eAST node defines the search space for the hole, i.e., a set of expressions and values. JAttack generates programs by executing templates and filling each hole by randomly choosing expressions and values (available within the search space defined by the hole). Additionally, we introduce several optimizations to reduce JAttack’s generation cost. While JAttack could be used to test various compiler features, we demonstrate its capabilities in helping test just-in-time (JIT) Java compilers, whose optimizations occur at runtime after a sufficient number of executions. Using JAttack, we have found six critical bugs that were confirmed by Oracle developers. Four of them were previously unknown, including two unknown CVEs (Common Vulnerabilities and Exposures). JAttack shows the power of combining developers’ domain knowledge (via templates) with random testing to detect bugs in JIT compilers.