[infer][biabduction] no longer track the resources saved into a container

Reviewed By: sblackshear

Differential Revision: D7387371

fbshipit-source-id: 81f34cc
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent dcc0f646fe
commit 8cfbdef7e0

@ -29,7 +29,6 @@ public abstract class HashMap<K,V> {
private K lastKey1 = null;
private K lastKey2 = null;
private boolean containsResources = false;
public boolean containsKey(K key) {
// doesn't actually check if _containsKey(key). If you just put a
@ -55,10 +54,8 @@ public abstract class HashMap<K,V> {
public V put(K key, V value) {
if (value instanceof Closeable) {
// Transfer the resource ownership to the container
// assume the resource will be handled correctly in this case
InferBuiltins.__set_mem_attribute(value);
InferBuiltins.__set_file_attribute(this);
containsResources = true;
}
pushKey(key);
@ -77,10 +74,6 @@ public abstract class HashMap<K,V> {
public void clear() {
lastKey1 = null;
lastKey2 = null;
if (containsResources) {
InferBuiltins.__set_mem_attribute(this);
}
containsResources = false;
}
/** some sort of circular buffer simulator */

@ -6,7 +6,6 @@ codetoanalyze/java/infer/Builtins.java, void Builtins.doNotBlockError(Object), 3
codetoanalyze/java/infer/CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK, ERROR, [start of procedure sourceOfNullWithResourceLeak(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK, ERROR, [start of procedure failToCloseWithCloseQuietly(),start of procedure SomeResource(),return from a call to SomeResource.<init>(),start of procedure doSomething(),Skipping star(): method has no implementation,Definition of star(),Taking true branch,start of procedure LocalException(),return from a call to LocalException.<init>(),exception codetoanalyze.java.infer.LocalException,return from a call to void SomeResource.doSomething()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK, ERROR, [start of procedure leakFoundWhenIndirectlyImplementingCloseable(),start of procedure CloseableAsResourceExample$MyResource(...),return from a call to CloseableAsResourceExample$MyResource.<init>(CloseableAsResourceExample)]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClearinglocalMapContainingResourcesBad(), 4, RESOURCE_LEAK, ERROR, [start of procedure notClearinglocalMapContainingResourcesBad(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK, ERROR, [start of procedure notClosingCloseable(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK, ERROR, [start of procedure notClosingWrapper(),start of procedure Resource(),return from a call to Resource.<init>(),start of procedure Sub(...),start of procedure Wrapper(...),return from a call to Wrapper.<init>(Resource),return from a call to Sub.<init>(Resource),start of procedure close(),return from a call to void Resource.close()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK, ERROR, [start of procedure skippedVritualCallDoesNotCloseResourceOnReceiver(),start of procedure SomeResource(),return from a call to SomeResource.<init>(),Skipping foo(...): method has no implementation,Definition of foo(...)]

@ -213,7 +213,8 @@ public class CloseableAsResourceExample {
resourceMap.put(key, res);
}
void notClearinglocalMapContainingResourcesBad() {
// this case is not supported
void FN_notClearinglocalMapContainingResourcesBad() {
HashMap<Integer, Closeable> map = new HashMap<>();
SomeResource res = new SomeResource();
Integer key = 42;

@ -25,7 +25,6 @@ codetoanalyze/java/infer/ClassCastExceptions.java, void ClassCastExceptions.clas
codetoanalyze/java/infer/CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK, ERROR, [start of procedure sourceOfNullWithResourceLeak(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK, ERROR, [start of procedure failToCloseWithCloseQuietly(),start of procedure SomeResource(),return from a call to SomeResource.<init>(),start of procedure doSomething(),Skipping star(): method has no implementation,Definition of star(),Taking true branch,start of procedure LocalException(),return from a call to LocalException.<init>(),exception codetoanalyze.java.infer.LocalException,return from a call to void SomeResource.doSomething()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK, ERROR, [start of procedure leakFoundWhenIndirectlyImplementingCloseable(),start of procedure CloseableAsResourceExample$MyResource(...),return from a call to CloseableAsResourceExample$MyResource.<init>(CloseableAsResourceExample)]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClearinglocalMapContainingResourcesBad(), 4, RESOURCE_LEAK, ERROR, [start of procedure notClearinglocalMapContainingResourcesBad(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK, ERROR, [start of procedure notClosingCloseable(),start of procedure SomeResource(),return from a call to SomeResource.<init>()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK, ERROR, [start of procedure notClosingWrapper(),start of procedure Resource(),return from a call to Resource.<init>(),start of procedure Sub(...),start of procedure Wrapper(...),return from a call to Wrapper.<init>(Resource),return from a call to Sub.<init>(Resource),start of procedure close(),return from a call to void Resource.close()]
codetoanalyze/java/infer/CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK, ERROR, [start of procedure skippedVritualCallDoesNotCloseResourceOnReceiver(),start of procedure SomeResource(),return from a call to SomeResource.<init>(),Skipping foo(...): method has no implementation,Definition of foo(...)]

Loading…
Cancel
Save