This event has ended. View the official site or create your own event → Check it out
This event has ended. Create your own
View analytic
Thursday, March 17 • 15:20 - 16:00
Run-time type checking with clang, using libcrunch

Sign up or log in to save this to your schedule and see who's attending!

Existing sanitizers ASan and MSan add run-time checking for memory errors, both spatial and temporal. However, currently there is no analogous way to check for type errors. This talk describes a system for adding run-time type checks, largely checking pointer casts, at the Clang AST level.

Run-time type checking is important for three reasons. Firstly, type bugs such as bad pointer casts can lead to type-incorrect accesses that are spatially valid (in bounds) and temporally valid (accessing live memory), so are missed by MSan or ASan. Secondly, type-incorrect accesses which do trigger memory errors often do so only many instructions later, meaning that spatial or temporal violation warnings fail to pinpoint the root problem, making debugging difficult. Finally, given an awareness of type, it becomes possible to perform more precise spatial and temporal checking -- for example, recalculating pointer bounds after a cast, or perhaps even mark-and-sweep garbage collection.

Although still a research prototype, libcrunch can cope well with real C codebases, and supports a good complement of awkward language features. Experience shows that libcrunch reliably finds questionable pointer use, and often uncovers minor other bugs. It also naturally detects certain format string exploits. However, its main value is in debugging fresh, not-yet-committed code ("why is this segfaulting?"). Beside the warnings generated by failing checks, the runtime API is also available from the debugger, so can interactively answer questions like "what type is this really pointing to?".

avatar for Stephen Kell

Stephen Kell

University of Cambridge
interested in: tools, especially sanitiser-like tools; debugging infrastructure; linkers; various other things....

Thursday March 17, 2016 15:20 - 16:00

Attendees (16)