infer icon indicating copy to clipboard operation
infer copied to clipboard

javalib incompatibility causes infer -- javac Hello.java to fail with no files analyzed

Open wywlds opened this issue 11 years ago • 25 comments

the log trace is as below: wyw@wyw-System-Product-Name:~/workspace/test$ infer -- javac Hello.java TODO: print error message Starting analysis (Infer version v0.1.0) Fatal error: exception Sys_error("/home/wyw/workspace/test/infer-out/captured: No such file or directory") [ERROR] Failure during create_makefile, original command was

[u'inferJ', u'-g', u'-a', 'infer', u'javac', 'Hello.java']

Traceback (most recent call last): File "/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/inferJ", line 19, in stats = analysis.start() File "/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/inferlib.py", line 634, in start self.analyze_and_report() File "/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/inferlib.py", line 613, in analyze_and_report if self.analyze() == os.EX_OK: File "/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/inferlib.py", line 489, in analyze self.args.analyzer File "/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/inferlib.py", line 318, in run_command raise e subprocess.CalledProcessError: Command '[u'/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/InferAnalyze', u'-results_dir', '/home/wyw/workspace/test/infer-out', u'-makefile', u'Makefile', u'-allow_specs_cleanup', u'-models', u'/home/wyw/Downloads/infer-linux64-v0.1.0/infer/infer/bin/../lib/java/models.jar', u'-project_root', '/home/wyw/workspace/test']' returned non-zero exit status 2

Anyone could explain?

wywlds avatar Jun 12 '15 10:06 wywlds

Hello @wywlds, Have you tried running javac Hello.java and see if it compiles correctly? I suspect javac is not installed in your machine.

martinoluca avatar Jun 12 '15 10:06 martinoluca

@martinoluca I installed javac. Proof: wyw@wyw-System-Product-Name:~/workspace/test$ javac -version javac 1.7.0_06

wywlds avatar Jun 12 '15 11:06 wywlds

Thanks for reporting this. It seems that the execution reached the point where no source files were found:

https://github.com/facebook/infer/blob/master/infer/src/java/jMain.ml#L167

I suspect that we are having issues here with incompatible format:

https://github.com/facebook/infer/blob/master/infer/src/java/jClasspath.ml#L109

which leads to all the classes in the small example to be skipped.

But I would not know how to reproduce it.

jeremydubreil avatar Jun 12 '15 16:06 jeremydubreil

I'm getting the same error.

I've run the infer/scripts/test.sh script. The output is below:

staff-246-113:infer David$ ./scripts/test.sh 
+++ dirname ./scripts/test.sh
++ cd ./scripts
++ pwd
+ SCRIPT_DIR=/Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts
+ INFER_DIR=/Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts/..
+ INFER_BIN=/Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts/../infer/bin
+ '[' '' == --xml ']'
+ TARGETS_TO_COMPILE=()
+ TARGETS_TO_TEST=()
+ '[' -e /Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts/../infer/bin/InferJava ']'
+ TARGETS_TO_COMPILE+=('java')
+ TARGETS_TO_TEST+=('java')
++ uname
+ platform=Darwin
+ '[' -e /Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts/../infer/bin/InferClang ']'
+ TARGETS_TO_COMPILE+=('clang')
+ TARGETS_TO_TEST+=('c' 'cpp')
+ '[' Darwin == Darwin ']'
+ TARGETS_TO_TEST+=('objc')
+ '[' -z java ']'
+ '[' -z java ']'
+ cd /Users/David/Documents/Development/tools/infer-osx-v0.1.0/infer/scripts/..
+ make -C infer java clang
make: *** No rule to make target `java'.  Stop.

Maybe this will help.

Regards,

aussiDavid avatar Jun 13 '15 03:06 aussiDavid

I've managed to get this working. Upgraded my java installation to:

$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

and downgraded my javac to:

$ javac -version
javac 1.7.0_79

as @jeremydubreil said, looks like compatibility issues.

aussiDavid avatar Jun 13 '15 04:06 aussiDavid

@aussiDavid: Good point! Which version of Java were you using before ?

@wywlds: Can you please check which implementation of Java are you using with java -version ?

jeremydubreil avatar Jun 13 '15 04:06 jeremydubreil

@jeremydubreil: I'm not 100% sure. From memory it was v1.6~.

aussiDavid avatar Jun 13 '15 04:06 aussiDavid

I upgraded from build 1.7.0_75-b13 to 1.7.0_79 but no joy. I'll be more then happy to help troubleshooting . Infer looks so promising!

icaspi avatar Jun 13 '15 04:06 icaspi

@icaspi: what do you get if you do: java -version ?

jeremydubreil avatar Jun 13 '15 04:06 jeremydubreil

java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

icaspi avatar Jun 13 '15 04:06 icaspi

@icaspi: Thanks! Should normally be working with this version. Which platform are you trying this on ?

jeremydubreil avatar Jun 13 '15 04:06 jeremydubreil

OSX 10.10.3

icaspi avatar Jun 13 '15 04:06 icaspi

@icaspi: OK, so nothing we did not test with. Did you try modifying the example file Hello.java a bit and check if it is always failing

jeremydubreil avatar Jun 13 '15 05:06 jeremydubreil

@jeremydubreil Sorry I forgot to mention I'm running it using a gradle build on a somewhat of a complex project I'll try to run it on a hello world in a few hours and get back to you, thank you so much!

icaspi avatar Jun 13 '15 05:06 icaspi

Same problem. I have two java environments for choice. The problem remains on both two versions.

export JAVA_6_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
export JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

export JAVA_HOME=$JAVA_7_HOME

alias jdk7='export JAVA_HOME=$JAVA_7_HOME'
alias jdk6='export JAVA_HOME=$JAVA_6_HOME'

wzpan avatar Jun 13 '15 06:06 wzpan

I have the same issue:

OSX 10.10.3, java version "1.7.0_71" ,Python 2.7.6

loulijun:test loulijun$ infer -- javac Hello.java 
TODO: print error message
Starting analysis (Infer version v0.1.0)
Fatal error: exception Sys_error("/Users/loulijun/test/infer-out/captured: No such file or directory")
[ERROR] Failure during create_makefile, original command was

[u'inferJ', u'-g', u'-a', 'infer', u'javac', 'Hello.java']


Traceback (most recent call last):
  File "/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/inferJ", line 19, in <module>
    stats = analysis.start()
  File "/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/inferlib.py", line 634, in start
    self.analyze_and_report()
  File "/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/inferlib.py", line 613, in analyze_and_report
    if self.analyze() == os.EX_OK:
  File "/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/inferlib.py", line 489, in analyze
    self.args.analyzer
  File "/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/inferlib.py", line 318, in run_command
    raise e
subprocess.CalledProcessError: Command '[u'/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/InferAnalyze', u'-results_dir', '/Users/loulijun/test/infer-out', u'-makefile', u'Makefile', u'-allow_specs_cleanup', u'-models', u'/Users/loulijun/application/infer/infer-osx-v0.1.0/infer/infer/bin/../lib/java/models.jar', u'-project_root', '/Users/loulijun/test']' returned non-zero exit status 2

loulijun avatar Jun 13 '15 10:06 loulijun

@jeremydubreil Hello.java is working fine I believe this the problem -

At first it complained about LeakCanary (https://github.com/square/leakcanary) I suspect its something with its lint release configuration, after removing LeakCanary it complains about this -

22:41:36.360 [ERROR] [org.gradle.BuildExceptionReporter] 22:41:36.360 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception. 22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter] 22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong: 22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':libraries:facebook:lint'. 22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter] > Lint found errors in the project; aborting build. 22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter]
22:41:36.361 [ERROR] [org.gradle.BuildExceptionReporter] Fix the issues identified by lint, or add the following to your build script to proceed with errors: 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] ... 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] android { 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] lintOptions { 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] abortOnError false 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] } 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] } 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] ... 22:41:36.362 [ERROR] [org.gradle.BuildExceptionReporter] 22:41:36.363 [ERROR] [org.gradle.BuildExceptionReporter] * Try: 22:41:36.363 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.

My release config (gradle clean assembleGoogleRelease) is building fine...

Any ideas?

icaspi avatar Jun 13 '15 19:06 icaspi

Waiting for solve this problem.

DoctorQ avatar Jun 14 '15 03:06 DoctorQ

Hi @icaspi, would you mind opening another issue for this problem, since running Infer on Hello.java seems to work for you? Many thanks!

jvillard avatar Jun 14 '15 11:06 jvillard

@jeremydubreil it's java 1.7.0_06 java version "1.7.0_06" Java(TM) SE Runtime Environment (build 1.7.0_06-b24) Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)

wywlds avatar Jun 15 '15 01:06 wywlds