[starvation][whole-program] more models

Summary: It never ends.

Reviewed By: ezgicicek

Differential Revision: D18832995

fbshipit-source-id: 52754afa1
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent 9c1bef41e7
commit 9df0c678de

@ -238,7 +238,13 @@ let schedules_work_on_ui_thread =
let matcher =
[ { default with
classname= "java.lang.Object"
; methods= ["postOnUiThread"; "runOnUiThread"; "postOnUiThreadDelayed"] } ]
; methods=
[ "postOnUiThread"
; "postOnUiThreadDelayed"
; "postToUiThread"
; "runOnUiThread"
; "runOnUiThreadAsync"
; "runOnUiThreadAsyncWithDelay" ] } ]
|> of_records
in
fun tenv pname -> matcher tenv pname []
@ -316,6 +322,8 @@ let get_returned_executor ~attrs_of_pname tenv callee actuals =
match Typ.Procname.Java.get_method java_pname with
| ("getForegroundExecutor" | "getBackgroundExecutor") when Lazy.force type_check ->
Some ForNonUIThread
| "getUiThreadExecutorService" when Lazy.force type_check ->
Some ForUIThread
| _ ->
None )
| _ ->
@ -324,26 +332,26 @@ let get_returned_executor ~attrs_of_pname tenv callee actuals =
let is_getMainLooper =
let open MethodMatcher in
[ { default with
of_record
{ default with
classname= "android.os.Looper"
; methods= ["getMainLooper"]
; actuals_pred= List.is_empty } ]
|> of_records
; actuals_pred= List.is_empty }
let is_handler_constructor =
let open MethodMatcher in
[ { default with
of_record
{ default with
classname= "android.os.Handler"
; methods= [Typ.Procname.Java.constructor_method_name]
; actuals_pred= (fun actuals -> not (List.is_empty actuals)) } ]
|> of_records
; actuals_pred= (fun actuals -> not (List.is_empty actuals)) }
let is_thread_constructor =
let open MethodMatcher in
[ { default with
of_record
{ default with
classname= "java.lang.Thread"
; search_superclasses= false
; methods= [Typ.Procname.Java.constructor_method_name] } ]
|> of_records
; methods= [Typ.Procname.Java.constructor_method_name] }

@ -23,6 +23,8 @@ class Executors {
public static void postOnUiThread(Runnable runnable) {}
public static void postToUiThread(Runnable runnable) {}
public static void runOnUiThread(Runnable runnable) {}
public static void postOnUiThreadDelayed(Runnable runnable, long delayMs) {}

@ -160,4 +160,14 @@ class ModeledExecutors {
}
});
}
public void postToUIThreadBad() {
Executors.postToUiThread(
new Runnable() {
@Override
public void run() {
doTransact();
}
});
}
}

@ -11,6 +11,7 @@ codetoanalyze/java/starvation-whole-program/DirectStarvation.java, DirectStarvat
codetoanalyze/java/starvation-whole-program/ImplicitConstructor.java, ImplicitConstructor.postBlockingCallToUIExecutorBad():void, 54, STARVATION, no_bucket, ERROR, [`void ImplicitConstructor.postBlockingCallToUIExecutorBad()`,Method call: `void ImplicitConstructor$1.run()`,Method call: `void ImplicitConstructor.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`]
codetoanalyze/java/starvation-whole-program/ImplicitConstructor.java, ImplicitConstructor.postBlockingCallToUIHandlerBad():void, 66, STARVATION, no_bucket, ERROR, [`void ImplicitConstructor.postBlockingCallToUIHandlerBad()`,Method call: `void ImplicitConstructor$1.run()`,Method call: `void ImplicitConstructor.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`]
codetoanalyze/java/starvation-whole-program/IndirectStarvation.java, IndirectStarvation.postBlockingCallToBackgroundThreadAndLockBad():void, 32, STARVATION, no_bucket, ERROR, [[Trace 1] `void IndirectStarvation.postBlockingCallToBackgroundThreadAndLockBad()`,Method call: `void IndirectStarvation$1.run()`, locks `this.monitorA` in `class IndirectStarvation`,[Trace 2] `void IndirectStarvation.postBlockingCallToBackgroundThreadAndLockBad()`,Method call: `void IndirectStarvation$2.run()`, locks `this.monitorA` in `class IndirectStarvation`,Method call: `void IndirectStarvation.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`]
codetoanalyze/java/starvation-whole-program/ModeledExecutors.java, ModeledExecutors.postToUIThreadBad():void, 165, STARVATION, no_bucket, ERROR, [`void ModeledExecutors.postToUIThreadBad()`,Method call: `void ModeledExecutors$12.run()`,Method call: `void ModeledExecutors.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`]
codetoanalyze/java/starvation-whole-program/ModeledExecutors.java, ModeledExecutors.scheduleBlockingCallToUIThreadBad():void, 140, STARVATION, no_bucket, ERROR, [`void ModeledExecutors.scheduleBlockingCallToUIThreadBad()`,Method call: `void ModeledExecutors$10.run()`,Method call: `void ModeledExecutors.doTransact()`,calls `boolean Binder.transact(int,Parcel,Parcel,int)`]
codetoanalyze/java/starvation-whole-program/ModeledExecutors.java, ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad():void, 97, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad()`,Method call: `void ModeledExecutors$7.run()`, locks `this.monitorA` in `class ModeledExecutors`, locks `this.monitorB` in `class ModeledExecutors`,[Trace 2] `void ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad()`,Method call: `void ModeledExecutors$8.run()`, locks `this.monitorB` in `class ModeledExecutors`, locks `this.monitorA` in `class ModeledExecutors`]
codetoanalyze/java/starvation-whole-program/ModeledExecutors.java, ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad():void, 110, DEADLOCK, no_bucket, ERROR, [[Trace 1] `void ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad()`,Method call: `void ModeledExecutors$8.run()`, locks `this.monitorB` in `class ModeledExecutors`, locks `this.monitorA` in `class ModeledExecutors`,[Trace 2] `void ModeledExecutors.scheduleGuaranteedDelayedDeadlockBad()`,Method call: `void ModeledExecutors$7.run()`, locks `this.monitorA` in `class ModeledExecutors`, locks `this.monitorB` in `class ModeledExecutors`]

Loading…
Cancel
Save