facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.94k stars 2.01k forks source link

[help wanted] While trying to run racerd #773

Closed nabarunnag closed 6 years ago

nabarunnag commented 6 years ago

Following the instruction in the docs

RacerD finds data races in your Java code. To run the analysis, you can use plain infer (to run >RacerD along with other analyses that are run by default) or infer --racerd-only (to run only RacerD). For example, the command infer --racerd-only -- javac File.java will run RacerD on File.java.

I end up with this error

nnag:index/ (develop*) $ infer --racerd-only -- javac IndexManager.java [16:04:38] /usr/local/bin/infer: unknown option '--racerd-only'. Infer version v0.12.1 Copyright 2009 - present Facebook. All Rights Reserved.

sblackshear commented 6 years ago

RacerD is part of Infer release 0.13.0, but it looks like you're running with 0.12.1. Could you grab the latest release and see if it fixes your problem?

nabarunnag commented 6 years ago

By building from the tar using ./build-infer.sh or ./build-infer.sh java ends up with this error. Trying to figure out what is wrong.

[NOTE] Package re is already installed (current version is 1.7.1).
[NOTE] Package result is already installed (current version is 1.2).
[NOTE] Package sawja is already installed (current version is 1.5.2).
[NOTE] Package sexplib is already installed (current version is v0.9.2).
[NOTE] Package spawn is already installed (current version is v0.9.0).
[NOTE] Package sqlite3 is already installed (current version is 4.2.0).
[NOTE] Package stdio is already installed (current version is v0.9.0).
[NOTE] Package topkg is already installed (current version is 0.9.0).
[NOTE] Package typerep is already installed (current version is v0.9.0).
[NOTE] Package variantslib is already installed (current version is v0.9.0).
[NOTE] Package xmlm is already installed (current version is 1.3.0).
[NOTE] Package yojson is already installed (current version is 1.4.0).
rm: /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1/conf-autoconf-81019-5f1023.err: Permission denied
rm: /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1/conf-autoconf-81019-5f1023.out: Permission denied
rm: /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1/conf-autoconf-81019-5f1023.info: Permission denied
rm: /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1/conf-autoconf-81019-5f1023.env: Permission denied
rm: /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1: Directory not empty

#=== ERROR while installing conf-autoconf.0.1 =================================#
# opam-version    1.2.2
# os              darwin
Cannot remove /Users/nnag/.opam/infer-4.05.0+flambda/build/conf-autoconf.0.1 (error 1).
Exception:
Reqs_error
 (Process_error
   ("opam install -y ANSITerminal.0.7 atd.1.12.0 atdgen.1.12.0 base.v0.9.3 bin_prot.v0.9.1 biniou.1.2.0 camlp4.4.05+1 camlzip.1.07 cmdliner.1.0.2 conf-aclocal.1.0.0 conf-autoconf.0.1 conf-m4.1 conf-pkg-config.1.0 conf-which.1 configurator.v0.9.1 core.v0.9.1 core_kernel.v0.9.0 cppo.1.6.0 cppo_ocamlbuild.1.6.0 ctypes.0.13.0 easy-format.1.3.0 extlib-compat.1.7.2 fieldslib.v0.9.0 integers.0.2.2 jane-street-headers.v0.9.0 javalib.2.3.4 jbuilder.1.0+beta14 menhir.20170712 mtime.1.1.0 num.0 ocaml-compiler-libs.v0.9.0 ocaml-migrate-parsetree.1.0.6 ocamlbuild.0.11.0 ocamlfind.1.7.3 octavius.1.1.0 ounit.2.0.5 parmap.1.0-rc8 ppx_assert.v0.9.0 ppx_ast.v0.9.1 ppx_base.v0.9.0 ppx_bench.v0.9.1 ppx_bin_prot.v0.9.0 ppx_compare.v0.9.0 ppx_core.v0.9.0 ppx_custom_printf.v0.9.0 ppx_derivers.1.0 ppx_deriving.4.2 ppx_driver.v0.9.1 ppx_enumerate.v0.9.0 ppx_expect.v0.9.0 ppx_fail.v0.9.0 ppx_fields_conv.v0.9.0 ppx_hash.v0.9.0 ppx_here.v0.9.1 ppx_inline_test.v0.9.2 ppx_jane.v0.9.0 ppx_js_style.v0.9.0 ppx_let.v0.9.0 ppx_metaquot.v0.9.0 ppx_optcomp.v0.9.0 ppx_optional.v0.9.0 ppx_pipebang.v0.9.0 ppx_sexp_conv.v0.9.0 ppx_sexp_message.v0.9.0 ppx_sexp_value.v0.9.0 ppx_tools.5.0+4.05.0 ppx_traverse.v0.9.0 ppx_traverse_builtins.v0.9.0 ppx_type_conv.v0.9.0 ppx_typerep_conv.v0.9.0 ppx_variants_conv.v0.9.0 re.1.7.1 result.1.2 sawja.1.5.2 sexplib.v0.9.2 spawn.v0.9.0 sqlite3.4.2.0 stdio.v0.9.0 topkg.0.9.0 typerep.v0.9.0 variantslib.v0.9.0 xmlm.1.3.0 yojson.1.4.0 --color=never",
   Unix.WEXITED 4)).

*** ERROR: `install_opam_deps` failed
nabarunnag commented 6 years ago

Hi I switched to an Ubuntu 16.04.3 LTS machine from a MacOS machine and was able to successfully build the 0.13.0 source, but when I am running the command "infer run -- ./gradlew build -Dskip.tests=true -xjavadoc -xdoc" it ends up throwing the following error after the build is complete.

Usage Error: 
*** Failed to execute compilation command: exited with code 2
*** Command: 'javac' '@/home/nabarun/Documents/codeWork/gemfire/gemfire/open/infer-out/filelists/gradle_v9Mftc.txt' '@/tmp/args_88a3b7'
*** Output:
javac: -classpath requires an argument
Usage: javac <options> <source files>
use -help for a list of possible options

*** Infer needs a working compilation command to run.

Failed to execute: /usr/local/lib/infer/infer/lib/python/inferlib/../../../bin/infer capture --continue -- javac -source 1.8 -target 1.8 -d /home/nabarun/Documents/codeWork/gemfire/gemfire/open/geode-common/build/classes/main -encoding UTF-8 -g -sourcepath -proc:none -XDuseUnsharedTable=true -classpath @/home/nabarun/Documents/codeWork/gemfire/gemfire/open/infer-out/filelists/gradle_v9Mftc.txt
Traceback (most recent call last):
  File "/usr/local/lib/infer/infer/bin/../lib/python/infer.py", line 186, in <module>
    main()
  File "/usr/local/lib/infer/infer/bin/../lib/python/infer.py", line 168, in main
    capture_exitcode = imported_module.gen_instance(args, cmd).capture()
  File "/usr/local/lib/infer/infer/lib/python/inferlib/capture/gradle.py", line 217, in capture
    return util.run_compilation_commands(cmds, clean_cmd)
  File "/usr/local/lib/infer/infer/lib/python/inferlib/capture/util.py", line 46, in run_compilation_commands
    if cmd.start() != os.EX_OK:
  File "/usr/local/lib/infer/infer/lib/python/inferlib/jwlib.py", line 37, in start
    raise e
subprocess.CalledProcessError: Command '[u'/usr/local/lib/infer/infer/lib/python/inferlib/../../../bin/infer', u'capture', u'--continue', u'--', u'javac', u'-source', u'1.8', u'-target', u'1.8', u'-d', u'/home/nabarun/Documents/codeWork/gemfire/gemfire/open/geode-common/build/classes/main', u'-encoding', u'UTF-8', u'-g', u'-sourcepath', u'-proc:none', u'-XDuseUnsharedTable=true', u'-classpath', u'@/home/nabarun/Documents/codeWork/gemfire/gemfire/open/infer-out/filelists/gradle_v9Mftc.txt']' returned non-zero exit status 1

Error backtrace:
Raised at file "integration/Driver.ml", line 297, characters 16-78
Called from file "integration/Driver.ml", line 176, characters 2-16
Called from file "backend/infer.ml", line 23, characters 2-36
Called from file "backend/infer.ml", line 106, characters 6-52
Uncaught error: ("InferModules__Driver.Infer_error(\"exited with code 1\")")

But when I switch to 0.12.1 / build it and then run the same command on the same product in same environment. It runs perfectly.

Please advise. Do let me know if you need any other logs

jvillard commented 6 years ago

By building from the tar using ./build-infer.sh or ./build-infer.sh java ends up with this error.

Looks like autoconf is missing. Try installing these dependencies.

For the failed gradle run, can you paste the contents of /home/nabarun/Documents/codeWork/gemfire/gemfire/open/infer-out/filelists/gradle_v9Mftc.txt and /tmp/args_88a3b7?

nabarunnag commented 6 years ago

gradle_gnAPkM.txt

/mnt/hgfs/nnag/Development/devEnv_2/gemfire/open/geode-common/src/main/java/org/apache/geode/annotations/Experimental.java
/mnt/hgfs/nnag/Development/devEnv_2/gemfire/open/geode-common/src/main/java/org/apache/geode/annotations/TestingOnly.java

/tmp/args_66509e

'-verbose'
'-g'
'-source'
'1.8'
'-target'
'1.8'
'-d'
'/mnt/hgfs/nnag/Development/devEnv_2/gemfire/open/geode-common/build/classes/main'
'-encoding'
'UTF-8'
'-g'
'-sourcepath'
'-proc:none'
'-XDuseUnsharedTable=true'
'-classpath'
nabarunnag commented 6 years ago

I am running this on Apache Geode

git clone git@github.com:apache/geode.git 
cd geode
git checkout develop
./gradlew clean
infer run -- ./gradlew build -Dskip.tests=true
nabarunnag commented 6 years ago

@jvillard Thank you . i was able to fix the permission issues in MacOS high Sierra but unfortunately I hit the same usage error as Ubuntu 16.04LTS

jvillard commented 6 years ago

I think that's a Java9 issue. Can you switch to Java8? Otherwise you'll want to use infer from master to get 185e7f713111f370c2b1b8a71b2236e1a3b89e21

Closing as Java9 support is in master, but feel free to reopen if it doesn't work for you.