150 likes | 290 Views
Runtime checking of expressive heap assertions. Greta Yorsh , Martin Vechev , Eran Yahav , Bard Bloom. Motivation. Reliability of large software systems illusive concurrency bugs, misuse of interfaces static analysis are inherently limited
E N D
Runtime checking of expressive heap assertions Greta Yorsh, Martin Vechev, EranYahav, Bard Bloom
Motivation • Reliability of large software systems • illusive concurrency bugs, misuse of interfaces • static analysis are inherently limited • Vision: runtime analysis of deep semantic properties with low overhead • testing, debugging, and production • real applications • leverage available system cores
Our goal • Checking expressive heap assertions at runtime with low overhead • reuse components of parallel GC • Enable reasoning about path properties • sharing • reachability through/avoiding • disjointness • domination • object ownership (encapsulation) • thread ownership (concurrency) • stack ownership (escape analysis)
Motivating Example: JdbF public class ConnectionSource { private Connection conn; private boolean used; public Connection getConnection() throws SQLEx { if (!used) { used = true; return conn; } throw new SQLEx(...); } public class Database { private ConnectionManager cm; public int insert(...) throws MappingEx { Connection c = cm.getConnection(...); ... } ... } public class ConnectionManager { private Map conns = Collections.synchronizedMap(new HashMap()); public Connection getConnection(String s) throws MappingException { try { ConnectionSource c = conns.get(s); if (c != null) return c.getConnection(); throw new MappingException(...); } catch (SQLEx e) { ... } } ... }
Root current thread Running Running Static Thread Database Thread Stack Connection Manager Stack HashMap Connection Source Connection Source Connection Source Connection Connection Connection every connection is reachable from at most one thread
Root current thread Running Running Static Thread Database Thread Stack Connection Manager Stack HashMap Connection Source Connection Source Connection Source Connection Connection Connection every connection is reachable from at most one thread
Motivating Example: JdbF public class ConnectionSource { private Connection conn; private boolean used; public Connection getConnection() throws SQLEx { if (!used) { used = true; return conn; } throw new SQLEx(...); } public class Database { private ConnectionManager cm; public int insert(...) throws MappingEx { Connection c = cm.getConnection(...); assert Phalanx.getThreadReach(c,cm) == 1 ... } ... } every connection is only reachable from one thread (avoiding connection manager) public class ConnectionManager { private Map conns = Collections.synchronizedMap(new HashMap()); public Connection getConnection(String s) throws MappingException { try { ConnectionSource c = conns.get(s); if (c != null) return c.getConnection(); throw new MappingException(...); } catch (SQLEx e) { ... } } ... }
Tool: Phalanx • JML extended with additional primitives • reach(Object o, Object[] avoiding) • pred(Object o) • dom(Object o1,Object o2) • … • Modified JML compiler maps common queries to efficient implementation in Phalanx runtime
Subtle Semantics • dom(x,y)
Experimental evaluation • Implementation on top of QVM platform • IBM J9 production virtual machine • can leverage QVM adaptive overhead manager • new parallel algorithms for common queries • Implementation based on JVMTI • less efficient, no parallel algorithms • portable
Disposal of Shared SWT Resources • replace code of the form: exp.dispose(); • with code of the form if (Phalanx.isShared(exp)) Phalanx.warning(”disposal of \ shared resource”+exp) ; exp.dispose();
Redundant Synchronization • replace code of the form: synchronized(exp) { ... } • with code of the form synchronized(exp) { if(Phalanx.dom(Thread.currentThread(),exp)) Phalanx.warning(”synchronization on \ an owned object”+exp) ; ... }
Summary • common heap queries and usage scenarios • new JML primitives • modified JML compiler • subtle semantics • implementation • parallel implementation in J9 production jvm • portable implementation in JVMTI • experimental evaluation • real-world applications • performance benchmarks