reprogrammer / keshmesh

Keshmesh is a static analysis tool for finding and fixing concurrency bug patterns in Java.
http://keshmesh.cs.illinois.edu/
Other
16 stars 5 forks source link

Detect LCK01J #33

Closed reprogrammer closed 12 years ago

reprogrammer commented 13 years ago

LCK01J describes bad synchronizations that use reusable objects as locks.

This is a fairly simple bug pattern to detect for it doesn't require interprocedural data flow analysis.

However, it isn't sufficient to check the type of lock objects to accurately detect LCK01J. For example, boolean literals (Boolean.FALSE and Boolean.TRUE) are reused but new Boolean(false) and new Boolean(true) aren't. Similarly, boxed primitives may be reused but non-box Integers may not. Likewise, string literals such as "STRING_LITERAL" and interned strings such as new String("STRING_LITERAL").intern() are reused but string objects such as new String("STRING_LITERAL") are not.

samira-t commented 13 years ago

@Wanderer777, @reprogrammer: When I get the pointed instances of a lock object used in a synchronized block, WALA returns me a node with the type of NormalAllocationNode. When the lock object is an auto-boxed Integer such as Integer a = 3; and I call normalAllocationNode.getNode().getMethod() WALA just gives me valueOf. However, it should return both Integer.IntegerChache and Integer.valueOf because some of the auto-boxed Integer's are created in Integer.valueOf while some others are created in the static initializer of Integer.IntegerCache.