Lenient Execution of C on a JVM -- How I Learned to Stop Worrying and Execute the Code

Lenient Execution of C on a JVM -- How I Learned to Stop Worrying and Execute the Code

Manuel Rigger, Roland Schatz, Matthias Grimmer, Hanspeter Moessenboeck

16 June 2017

Most C programs do not strictly conform to the C standard, and often show undefined behavior, e.g., on signed integer overflow. When compiled by non-optimizing compilers, such programs often behave as the programmer intended. However, optimizing compilers may exploit undefined semantics for more aggressive optimizations, thus possibly breaking the code. Analysis tools can help to find and fix such issues. Alternatively, one could define a C dialect in which clear semantics are defined for frequent program patterns whose behavior would otherwise be undefined. In this paper, we present such a dialect, called Lenient C, that specifies semantics for behavior that the standard left open for interpretation. Specifying additional semantics enables programmers to safely rely on otherwise undefined patterns. Lenient C aims towards being executed on a managed runtime such as the JVM. We demonstrate how we implemented the dialect in Safe Sulong, a C interpreter with a dynamic compiler that runs on the JVM.


Venue : ManLang'17 in Prague (http://d3s.mff.cuni.cz/conferences/manlang17/?n=Main.CfP)