From a6e5ab7fdb0b53feabc67ac0abcfa8fc2f106192 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Tue, 11 Sep 2018 19:55:11 -0700 Subject: [PATCH] [starvation][strict mode] disable strict mode violation reporting and analysis by default Summary: Turn off by default until mature enough. Also rename the dev-strict-mode test dir to highlight the dev part. Reviewed By: mbouaziz Differential Revision: D9775571 fbshipit-source-id: c3a41bbdf --- Makefile | 2 +- infer/src/base/Config.ml | 7 ++++++ infer/src/base/Config.mli | 2 ++ infer/src/concurrency/StarvationModels.ml | 25 +++++++++++-------- .../{strictmode => devstrictmode}/Makefile | 0 .../NonPublicGuardTest.java | 0 .../dalvik/system/BlockGuard.java | 0 .../java/devstrictmode/issues.exp | 4 +++ .../java/GuardTest.java | 0 .../codetoanalyze/java/strictmode/issues.exp | 4 --- 10 files changed, 28 insertions(+), 16 deletions(-) rename infer/tests/codetoanalyze/java/{strictmode => devstrictmode}/Makefile (100%) rename infer/tests/codetoanalyze/java/{strictmode => devstrictmode}/NonPublicGuardTest.java (100%) rename infer/tests/codetoanalyze/java/{strictmode => devstrictmode}/dalvik/system/BlockGuard.java (100%) create mode 100644 infer/tests/codetoanalyze/java/devstrictmode/issues.exp rename infer/tests/codetoanalyze/java/{strictmode => devstrictmode}/java/GuardTest.java (100%) delete mode 100644 infer/tests/codetoanalyze/java/strictmode/issues.exp diff --git a/Makefile b/Makefile index b69c38468..f5b0e649a 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ BUILD_SYSTEMS_TESTS += \ DIRECT_TESTS += \ java_checkers java_eradicate java_infer java_lab java_tracing java_quandary \ java_racerd java_stability java_crashcontext java_hoisting java_starvation java_performance \ - java_strictmode + java_devstrictmode ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index b211427f4..6c878318d 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2129,6 +2129,11 @@ and profiler_samples = $(b,--test-determinator)." +and starvation_strict_mode = + CLOpt.mk_bool ~long:"starvation-strict-mode" ~default:false + "During starvation analysis, report strict mode violations (Android only)" + + and testing_mode = CLOpt.mk_bool ~deprecated:["testing_mode"; "-testing_mode"; "tm"] @@ -2933,6 +2938,8 @@ and stacktraces_dir = !stacktraces_dir and starvation = !starvation +and starvation_strict_mode = !starvation_strict_mode + and stats_report = !stats_report and subtype_multirange = !subtype_multirange diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 6113011d3..699f1dfa3 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -622,6 +622,8 @@ val stacktraces_dir : string option val starvation : bool +val starvation_strict_mode : bool + val stats_report : string option val subtype_multirange : bool diff --git a/infer/src/concurrency/StarvationModels.ml b/infer/src/concurrency/StarvationModels.ml index 13c4c9a01..d65d06639 100644 --- a/infer/src/concurrency/StarvationModels.ml +++ b/infer/src/concurrency/StarvationModels.ml @@ -214,20 +214,23 @@ let strict_mode_matchers = (StrictModeModels.is_strict_mode_violation, High) :: strict_mode_common_matchers -(* at most one function is allowed to be true, sort from High to Low *) -let may_block = +let standard_matchers = let open StarvationDomain.Event in + [ (is_accountManager_setUserData, High) + ; (is_two_way_binder_transact, High) + ; (is_countdownlatch_await, High) + ; (is_thread_sleep, High) + ; (is_object_wait, High) + ; (is_asyncTask_get, Low) + ; (is_future_get, Low) ] + + +(* sort from High to Low *) +let may_block = let matchers = if Config.dev_android_strict_mode then strict_mode_seed_matchers - else - strict_mode_matchers - @ [ (is_accountManager_setUserData, High) - ; (is_two_way_binder_transact, High) - ; (is_countdownlatch_await, High) - ; (is_thread_sleep, High) - ; (is_object_wait, High) - ; (is_asyncTask_get, Low) - ; (is_future_get, Low) ] + else if Config.starvation_strict_mode then strict_mode_matchers @ standard_matchers + else standard_matchers in fun tenv pn actuals -> List.find_map matchers ~f:(fun (matcher, sev) -> Option.some_if (matcher tenv pn actuals) sev) diff --git a/infer/tests/codetoanalyze/java/strictmode/Makefile b/infer/tests/codetoanalyze/java/devstrictmode/Makefile similarity index 100% rename from infer/tests/codetoanalyze/java/strictmode/Makefile rename to infer/tests/codetoanalyze/java/devstrictmode/Makefile diff --git a/infer/tests/codetoanalyze/java/strictmode/NonPublicGuardTest.java b/infer/tests/codetoanalyze/java/devstrictmode/NonPublicGuardTest.java similarity index 100% rename from infer/tests/codetoanalyze/java/strictmode/NonPublicGuardTest.java rename to infer/tests/codetoanalyze/java/devstrictmode/NonPublicGuardTest.java diff --git a/infer/tests/codetoanalyze/java/strictmode/dalvik/system/BlockGuard.java b/infer/tests/codetoanalyze/java/devstrictmode/dalvik/system/BlockGuard.java similarity index 100% rename from infer/tests/codetoanalyze/java/strictmode/dalvik/system/BlockGuard.java rename to infer/tests/codetoanalyze/java/devstrictmode/dalvik/system/BlockGuard.java diff --git a/infer/tests/codetoanalyze/java/devstrictmode/issues.exp b/infer/tests/codetoanalyze/java/devstrictmode/issues.exp new file mode 100644 index 000000000..40b303380 --- /dev/null +++ b/infer/tests/codetoanalyze/java/devstrictmode/issues.exp @@ -0,0 +1,4 @@ +codetoanalyze/java/devstrictmode/java/GuardTest.java, java.GuardTest.intraprocBad():void, 29, STARVATION, no_bucket, ERROR, [`void GuardTest.intraprocBad()`,Method call: `void GuardTest.privateOk()`,Method call: `void GuardTest.testReadBad()`,calls `void BlockGuard$Policy.onReadFromDisk()` from `void GuardTest.testReadBad()`] +codetoanalyze/java/devstrictmode/java/GuardTest.java, java.GuardTest.testNetBad():void, 21, STARVATION, no_bucket, ERROR, [`void GuardTest.testNetBad()`,calls `void BlockGuard$Policy.onNetwork()` from `void GuardTest.testNetBad()`] +codetoanalyze/java/devstrictmode/java/GuardTest.java, java.GuardTest.testReadBad():void, 17, STARVATION, no_bucket, ERROR, [`void GuardTest.testReadBad()`,calls `void BlockGuard$Policy.onReadFromDisk()` from `void GuardTest.testReadBad()`] +codetoanalyze/java/devstrictmode/java/GuardTest.java, java.GuardTest.testWriteBad():void, 13, STARVATION, no_bucket, ERROR, [`void GuardTest.testWriteBad()`,calls `void BlockGuard$Policy.onWriteToDisk()` from `void GuardTest.testWriteBad()`] diff --git a/infer/tests/codetoanalyze/java/strictmode/java/GuardTest.java b/infer/tests/codetoanalyze/java/devstrictmode/java/GuardTest.java similarity index 100% rename from infer/tests/codetoanalyze/java/strictmode/java/GuardTest.java rename to infer/tests/codetoanalyze/java/devstrictmode/java/GuardTest.java diff --git a/infer/tests/codetoanalyze/java/strictmode/issues.exp b/infer/tests/codetoanalyze/java/strictmode/issues.exp deleted file mode 100644 index 227948afd..000000000 --- a/infer/tests/codetoanalyze/java/strictmode/issues.exp +++ /dev/null @@ -1,4 +0,0 @@ -codetoanalyze/java/strictmode/java/GuardTest.java, java.GuardTest.intraprocBad():void, 29, STARVATION, no_bucket, ERROR, [`void GuardTest.intraprocBad()`,Method call: `void GuardTest.privateOk()`,Method call: `void GuardTest.testReadBad()`,calls `void BlockGuard$Policy.onReadFromDisk()` from `void GuardTest.testReadBad()`] -codetoanalyze/java/strictmode/java/GuardTest.java, java.GuardTest.testNetBad():void, 21, STARVATION, no_bucket, ERROR, [`void GuardTest.testNetBad()`,calls `void BlockGuard$Policy.onNetwork()` from `void GuardTest.testNetBad()`] -codetoanalyze/java/strictmode/java/GuardTest.java, java.GuardTest.testReadBad():void, 17, STARVATION, no_bucket, ERROR, [`void GuardTest.testReadBad()`,calls `void BlockGuard$Policy.onReadFromDisk()` from `void GuardTest.testReadBad()`] -codetoanalyze/java/strictmode/java/GuardTest.java, java.GuardTest.testWriteBad():void, 13, STARVATION, no_bucket, ERROR, [`void GuardTest.testWriteBad()`,calls `void BlockGuard$Policy.onWriteToDisk()` from `void GuardTest.testWriteBad()`]