Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Leak Checker crash with IllegalArgumentException #5136

Closed
msridhar opened this issue May 10, 2022 · 0 comments · Fixed by #5137
Closed

Resource Leak Checker crash with IllegalArgumentException #5136

msridhar opened this issue May 10, 2022 · 0 comments · Fixed by #5137

Comments

@msridhar
Copy link
Contributor

Input:

  class Handler extends Thread {
      boolean running;
      static class Call { boolean isResponseDeferred() { return true; } }
    @Override
    public void run() {
      while (running) {
        Call call = null;
        try {
          if (running) {
            continue;
          }
        } catch (Exception e) {
        } finally {
            String s = call.isResponseDeferred() ? ", deferred" : "";
        }
      }
    }
  }

Output:

$ java -jar checker/dist/checker.jar -processor resourceleak /tmp/Handler.java
error: SourceChecker.typeProcess: unexpected Throwable (IllegalArgumentException) while processing /tmp/Handler.java; message: value already present: call.isResponseDeferred() ? ", deferred" : ""
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: /tmp/Handler.java
  Last visited tree at line 1 column 3:
    class Handler extends Thread {
  Exception: java.lang.IllegalArgumentException: value already present: call.isResponseDeferred() ? ", deferred" : ""; java.lang.IllegalArgumentException: value already present: call.isResponseDeferred() ? ", deferred" : ""
  	at org.checkerframework.com.google.common.collect.HashBiMap.put(HashBiMap.java:300)
  	at org.checkerframework.com.google.common.collect.HashBiMap.put(HashBiMap.java:281)
  	at org.checkerframework.checker.resourceleak.ResourceLeakAnnotatedTypeFactory.addTempVar(ResourceLeakAnnotatedTypeFactory.java:234)
  	at org.checkerframework.checker.resourceleak.ResourceLeakTransfer.visitTernaryExpression(ResourceLeakTransfer.java:49)
  	at org.checkerframework.checker.resourceleak.ResourceLeakTransfer.visitTernaryExpression(ResourceLeakTransfer.java:23)
  	at org.checkerframework.dataflow.cfg.node.TernaryExpressionNode.accept(TernaryExpressionNode.java:108)
  	at org.checkerframework.dataflow.analysis.AbstractAnalysis.callTransferFunction(AbstractAnalysis.java:349)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.callTransferFunction(ForwardAnalysisImpl.java:372)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysisBlock(ForwardAnalysisImpl.java:128)
  	at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysis(ForwardAnalysisImpl.java:105)
  	at org.checkerframework.framework.flow.CFAbstractAnalysis.performAnalysis(CFAbstractAnalysis.java:146)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.analyze(GenericAnnotatedTypeFactory.java:1507)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1404)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:1839)
  	at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:414)

FYI @Nargeshdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant