How to Build Static Checking Systems Using Orders of Magnitude Less Code

Fraser Brown, Andres Nötzli, Dawson Engler
2016 SIGPLAN notices  
Modern static bug finding tools are complex. They typically consist of hundreds of thousands of lines of code, and most of them are wedded to one language (or even one compiler). This complexity makes the systems hard to understand, hard to debug, and hard to retarget to new languages, thereby dramatically limiting their scope. This paper reduces the complexity of the checking system by addressing a fundamental assumption, the assumption that checkers must depend on a full-blown language
more » ... cation and compiler front end. Instead, our program checkers are based on drastically incomplete language grammars ("micro-grammars") that describe only portions of a language relevant to a checker. As a result, our implementation is tiny-roughly 2500 lines of code, about two orders of magnitude smaller than a typical system. We hope that this dramatic increase in simplicity will allow developers to use more checkers on more systems in more languages. We implement our approach in µchex, a language-agnostic framework for writing static bug checkers. We use it to build micro-grammar based checkers for six languages (C, the C preprocessor, C++, Java, JavaScript, and Dart) and find over 700 errors in real-world projects. /* nashorn/src/jdk/nashorn/internal/codegen/types/ BooleanType.java */ 131 } else if (to.isLong()) { 132 convert(method, OBJECT); 133 invokeStatic(method, JSType.TO_UINT32); 134 } else if (to.isLong()) { 135 convert(method, OBJECT); 136 invokeStatic(method, JSType.TO_LONG);
doi:10.1145/2954679.2872364 fatcat:tvlafoor4nbpxajyk6tmvpd4gi