Virtual Machine Introspection for Program Understanding and Debugging
Modern managed languages, such as Java and C#, derive many of their software engineering benefits from the use of virtual machines, which implement powerful features such as just-in-time compilation, dynamic class loading, and garbage collection. While the performance penalty of VMs has received significant attention, the information penalty has not: this extra layer of virtualization makes program behavior (and misbehavior) much more difficult to understand. The garbage collector, for example, takes over responsibility for freeing objects, eliminating a large class of memory errors. As a result, however, the programmer no longer knows when, or even if, particular objects are reclaimed. Our work explores a solution called VM introspection, which gives programmers an interface for asking the virtual machine specific questions about program behavior at runtime. Our focus is on information that is readily available or can be computed cheaply enough to make this technique suitable for deployed software.
In this talk I will describe GC Assertions, an introspective interface that allows programmers to express expected properties of data structures. Unlike ordinary assertions, GC assertions are checked by the garbage collector, which is in a unique position to gather information and answer questions about the lifetime, volume, and connectivity of objects in the heap. In many cases these heap properties are difficult or impossible to accurately verify by any other means. By piggybacking on existing garbage collector computations, our system is able to check large numbers of assertions with very low overhead – around 3% of total execution time. In addition, our error reporting mechanism provides a detailed explanation of assertion violations, including a complete path through the heap to the offending objects.