infer icon indicating copy to clipboard operation
infer copied to clipboard

gradle integration may swallow `javac` options

Open tomcati opened this issue 8 years ago • 10 comments

I use command: infer -- gradle build It happends error:

File "/usr/local/Cellar/infer/0.13.0/lib/infer/infer/bin/../lib/python/infer.py", line 186, in main() File "/usr/local/Cellar/infer/0.13.0/lib/infer/infer/bin/../lib/python/infer.py", line 168, in main capture_exitcode = imported_module.gen_instance(args, cmd).capture() File "/usr/local/Cellar/infer/0.13.0/lib/infer/infer/lib/python/inferlib/capture/gradle.py", line 217, in capture return util.run_compilation_commands(cmds, clean_cmd) File "/usr/local/Cellar/infer/0.13.0/lib/infer/infer/lib/python/inferlib/capture/util.py", line 46, in run_compilation_commands if cmd.start() != os.EX_OK: File "/usr/local/Cellar/infer/0.13.0/lib/infer/infer/lib/python/inferlib/jwlib.py", line 37, in start raise e

tomcati avatar Jan 29 '18 08:01 tomcati

/Volumes/xx/pms_android/core/libs/okhttp-3.2.0.jar:/Volumes/xx/pms_android/AdaptionPMS/libs/MPChartLib.jar:/Volumes/xx/pms_android/core/libs/core-3.2.1.jar:/Volumes/xx/pms_android/core/libs/okio-1.6.0.jar:/Users/tom/.gradle/caches/modules-2/files-2.1/com.android.databinding/baseLibrary/2.3.3/eb3399988a52099b0127e27fb5bed666eca86ace/baseLibrary-2.3.3.jar:/Users/tom/.gradle/caches/modules-2/files-2.1/com.googlecode.juniversalchardet/juniversalchardet/1.0.3/cd49678784c46aa8789c060538e0154013bb421b/juniversalchardet-1.0.3.jar:/Users/tom/Documents/adt-bundle-mac-x86_64-20131030/sdk/extras/android/m2repository/com/android/support/support-annotations/25.3.0/support-annotations-25.3.0.jar:/Volumes/xx/pms_android/AdaptionPMS/libs/M100_RFID_API.jar:/Volumes/xx/pms_android/core/libs/fastjson-1.1.52.android.jar:/Users/tom/.gradle/caches/modules-2/files-2.1/com.android.databinding/compiler/2.3.3/bf8a44e08f3f78c5cb5a782c36d57e9c63586549/compiler-2.3.3.jar:/Volumes/xx/pms_android/core/build/intermediates/bundles/default/classes.jar:/Volumes/xx/pms_android/core/build/intermediates/bundles/default/libs/core-3.2.1.jar:/Volumes/xx/pms_android/core/build/intermediates/bundles/default/libs/fastjson-1.1.52.android.jar:/Volumes/xx/pms_android/core/build/intermediates/bundles/default/libs/okhttp-3.2.0.jar:/Volumes/xx/pms_android/core/build/intermediates/bundles/default/libs/okio-1.6.0.jar:/Volumes/xx/pms_android/autolayout/build/intermediates/bundles/default/classes.jar:/Users/tom/.android/build-cache/37139fbe12e823a6b3803f60fd07fef5f4e1fd2e/output/jars/classes.jar:/Users/tom/.android/build-cache/37139fbe12e823a6b3803f60fd07fef5f4e1fd2e/output/jars/libs/BaiduLBS_Android.jar:/Users/tom/.android/build-cache/e756e86a530b39b72b642627084de886a8520394/output/jars/classes.jar:/Users/tom/.android/build-cache/c8588071b2a9b50dfc0e0608fac37594a5b9c214/output/jars/classes.jar:/Users/tom/.android/build-cache/1eb29b4810260cbd64fe23d87bba8e3288fb1093/output/jars/classes.jar:/Users/tom/.android/build-cache/e3e9d126673104077af20df3c1e8728a9a0ee62b/output/jars/classes.jar:/Users/tom/.android/build-cache/566c5996012651bc765d9dbe43d2483982cb465b/output/jars/classes.jar:/Users/tom/.android/build-cache/5525c3992ba96f4760fa5fedecd5b89d0540b685/output/jars/classes.jar:/Users/tom/.android/build-cache/56b3d0c2972f2be3e58f5e2d331a4aebf6cb24da/output/jars/classes.jar:/Users/tom/.android/build-cache/5651a84accf7b956909b26d42b2cbc017678e65c/output/jars/classes.jar:/Users/tom/.android/build-cache/99f0421d47551ce0efd0cd17763265a5b3ef9f36/output/jars/classes.jar:/Users/tom/.android/build-cache/cf4d9678b48a601a366b7ae1763dcd2f622b954c/output/jars/classes.jar:/Users/tom/.android/build-cache/0c815f35bb3b32dd011287fe65f1a02cfcb15460/output/jars/classes.jar:/Users/tom/.android/build-cache/146b6e361c2d1b2c006ceef0248a590c05ae3a1f/output/jars/classes.jar:/Users/tom/.android/build-cache/146b6e361c2d1b2c006ceef0248a590c05ae3a1f/output/jars/libs/internal_impl-25.0.1.jar:/Users/tom/.android/build-cache/4e3e7a7e5470c565e0d0e7bd087211b122c4c06a/output/jars/classes.jar:/Users/tom/.android/build-cache/4e3e7a7e5470c565e0d0e7bd087211b122c4c06a/output/jars/libs/internal_impl-25.0.1.jar:/Users/tom/.android/build-cache/0fc0fbcc0531b77e9b6eb7cfe36b9b59488bd5d7/output/jars/classes.jar:/Users/tom/.android/build-cache/0fc0fbcc0531b77e9b6eb7cfe36b9b59488bd5d7/output/jars/libs/internal_impl-25.0.1.jar:/Users/tom/.android/build-cache/c6f7d7dbe0f3132448128daaf1435976918f9887/output/jars/classes.jar:/Users/tom/.android/build-cache/c6f7d7dbe0f3132448128daaf1435976918f9887/output/jars/libs/internal_impl-25.0.1.jar:/Users/tom/.android/build-cache/cf14d9e974d0ee571a5c4afe498f2d5329ddd73a/output/jars/classes.jar:/Users/tom/.android/build-cache/cf14d9e974d0ee571a5c4afe498f2d5329ddd73a/output/jars/libs/internal_impl-25.0.1.jar 用法: javac

tomcati avatar Jan 29 '18 08:01 tomcati

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")")

tomcati avatar Jan 29 '18 08:01 tomcati

I have seen similar issues on 0.13.0 and 0.13.1. Looking at logs both here and in my env: the argument to -sourcepath is missing and the following -processorpath foo causes javac to return an error since -processorpath is consumed as argument to -sourcepath and foo argument to -processorpath is not recognized as a javac flag.

No such problem with 0.12.1.

laalto avatar Feb 05 '18 11:02 laalto

I am facing exactly the same issue.

arazabishov avatar Feb 19 '18 14:02 arazabishov

I am facing exactly the same issue.

AnyMarvel avatar Mar 07 '18 10:03 AnyMarvel

Hi all, sorry for the late reply. The gradle integration of infer is very crude and will fail horribly in many normal cases, in particular if there are spaces in paths or options with empty values. A better gradle integration (for instance as a plugin) would be much welcome. We do not use gradle internally, so it's not something that our team will do as we are unfamiliar with it.

Uber wrote a plugin some time ago, but stopped maintaining it because now they use okbuck to automatically change gradle projects into Buck projects. Buck is well supported by infer, so for now the most robust way to get infer to run on a gradle projects is to use okbuck, then pass the buck build command to infer instead of the gradle build command.

Hope this helps. If anyone is interested in contributing a gradle plugin I'd be happy to help.

jvillard avatar Mar 21 '18 11:03 jvillard

I'd love to see better support for Gradle and Maven, thus fixing issues like this one. You have suggested using OKBuck, which experiments have shown is not easily automatable.

What if we developed a plugin for Gradle that produced a compilation database and patched infer to accept compilation databases for non-C programs? This would take non-trivial effort but the compilation database path seems much better supported than several other build systems, make included. If these broad strokes sound acceptable then we'll consider investing the hours to make a gradle plugin and see where we land on the infer modifications.

TomMD avatar May 14 '18 15:05 TomMD

@TomMD that plan sounds very sensible to me. I think going through a compilation database is a great way to not have infer having to care about which build system the project is using.

jvillard avatar May 16 '18 10:05 jvillard

I think this particular issue with gradle was fixed in 0.15.0 by 863e08909e785dc6e596dfd03076a63924c5b81b. Please re-open if that doesn't work for you with the latest version of infer.

jvillard avatar Jul 04 '18 12:07 jvillard

I get a similar error. Does anyone have an idea as to why this might have happened?

Capturing in gradle mode... Running and capturing gradle compilation...

2020-10-18T21:14:15.664+0800 [ERROR] [org.gradle.api.internal.tasks.testing.logging.TestCountLogger] 96 tests completed, 1 failed, 7 skipped 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':file-events:test'. 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > There were failing tests. See the report at: file:///Users/alaukik/code/PCDP/Assignments/Programming/DataRace-alaukik/native-platform/file-events/build/reports/tests/test/index.html 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2020-10-18T21:14:15.780+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try: 2020-10-18T21:14:15.781+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights. 2020-10-18T21:14:15.781+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 2020-10-18T21:14:15.781+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org 2020-10-18T21:14:15.781+0800 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 2020-10-18T21:14:15.781+0800 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 1m 47s ERROR: couldn't run compilation command [u'./gradlew', '--debug', u'build'] Internal Error: /usr/local/Cellar/infer/0.17.0/lib/infer/infer/bin/../lib/python/infer.py -j 4 --project-root /Users/alaukik/code/PCDP/Assignments/Programming/DataRace-alaukik/native-platform --out /Users/alaukik/code/PCDP/Assignments/Programming/DataRace-alaukik/native-platform/infer-out -- ./gradlew build: exited with code 1 Error backtrace: Raised at file "string.ml", line 145, characters 16-31 Called from file "string.ml" (inlined), line 149, characters 17-46 Called from file "src/string.ml", line 407, characters 12-33 Called from file "src/string.ml", line 416, characters 11-33 Re-raised at file "base/Die.ml", line 26, characters 8-56 Called from file "integration/Driver.ml", line 171, characters 2-16 Called from file "integration/Driver.ml", line 272, characters 6-409 Called from file "integration/Driver.ml", line 323, characters 2-29 Called from file "base/Utils.ml", line 398, characters 16-20 Called from file "scuba/ScubaLogging.ml", line 66, characters 29-44 Called from file "infer.ml", line 20, characters 2-36 Called from file "base/Utils.ml", line 398, characters 16-20 Called from file "scuba/ScubaLogging.ml", line 66, characters 29-44 Called from file "infer.ml", line 137, characters 8-54

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

alaukiknpant avatar Oct 18 '20 13:10 alaukiknpant