facebook / infer

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

Gradle problems with infer - build works on its own, but not with infer #1730

Closed ZwickPhilippe closed 1 year ago

ZwickPhilippe commented 1 year ago

Please make sure your issue is not addressed in the FAQ.

I was able to use infer on a small gradle project created by me (only 1 function next to main) and it worked perfectly. Afterwards I tried using infer on the Spring Framework, cloned their git and was able to build the project using ./gradlew build -x test. I want to note that after every build I cleaned using ./gradlew clean according to your documentation.

However, the ./gradlew build -x test is not working in combination with infer and I keep getting errors (also tried on other OSS gradle projects, but I ran into the same issues). As I am new to infer I would like to know if I do something wrong or if I am missing something in regards to permissions/dependencies.

Please include the following information:

Error backtrace: Raised at BaseString.index_from_exn_internal in file "src/string.ml", line 96, characters 7-22 Called from BaseString.lsplit2_exn.lsplit2_exn in file "src/string.ml", line 610, characters 14-54 Called from BaseString.lsplit2 in file "src/string.ml", line 628, characters 11-33 Re-raised at IBaseDie.raise_error.do_raise in file "src/base/Die.ml" (inlined), line 26, characters 8-56 Called from IBaseLogging.die.(fun) in file "src/base/Logging.ml", line 347, characters 6-39 Called from Integration__Gradle.run_gradle in file "src/integration/Gradle.ml", line 65, characters 2-68 Called from IntegrationDriver.capture in file "src/integration/Driver.ml", line 133, characters 6-32 Called from IBaseUtils.timeit in file "src/base/Utils.ml", line 429, characters 16-20 Called from IBaseScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 79, characters 29-44 Called from IntegrationDriver.capture.(fun) in file "src/integration/Driver.ml", line 159, characters 2-233 Called from BackendGCStats.log_f in file "src/backend/GCStats.ml" (inlined), line 90, characters 10-14 Called from IntegrationDriver.capture in file "src/integration/Driver.ml", line 157, characters 2-288 Called from DuneexeInfer.run in file "src/infer.ml" (inlined), line 20, characters 2-36 Called from IBaseUtils.timeit in file "src/base/Utils.ml" (inlined), line 429, characters 16-20 Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 79, characters 29-44 Called from DuneexeInfer.run in file "src/infer.ml", line 25, characters 22-94

Run the command again with --keep-going to try and ignore this error.


- [X] If possible, a minimal example to reproduce your problem (for instance, some code where
    infer reports incorrectly, together with the way you run infer to reproduce the incorrect
    report).
To reproduce this issue, one can clone from  [Spring Framework](https://github.com/spring-projects/spring-framework) and execute `infer run -- ./gradlew build -x test`. 

Thanks in advance!
ngorogiannis commented 1 year ago

The build task is trying to do something that Infer's integration can't work with.

Generally, you only need to build the task that compiles the classes you want to capture, but each gradle set up is different, so I can't give you a general recipe.

Sometime assemble will work better, otherwise try to browse the config files, or to list the tasks to see what's best.

ZwickPhilippe commented 1 year ago

Thank you very much for you quick reply! I guess I misunderstood it, as I thought, that as long as the project is able to build on its own, infer will always work.