no dynamic visibility

Summary:
Don't assign different visibilities to the same issue type dynamically,
use different issue types with always static visibility instead. This is
to be able to document the visibility of each issue type.

Reviewed By: dulmarod

Differential Revision: D21686458

fbshipit-source-id: 876ab4157
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 94fbd3977e
commit bc669c6c9f

@ -397,6 +397,7 @@ OPTIONS
CROSS_SITE_SCRIPTING (enabled by default), CROSS_SITE_SCRIPTING (enabled by default),
Cannot_star (enabled by default), Cannot_star (enabled by default),
DANGLING_POINTER_DEREFERENCE (disabled by default), DANGLING_POINTER_DEREFERENCE (disabled by default),
DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default),
DEADLOCK (enabled by default), DEADLOCK (enabled by default),
DEAD_STORE (enabled by default), DEAD_STORE (enabled by default),
DEALLOCATE_STACK_VARIABLE (enabled by default), DEALLOCATE_STACK_VARIABLE (enabled by default),
@ -466,6 +467,7 @@ OPTIONS
LOGGING_PRIVATE_DATA (enabled by default), LOGGING_PRIVATE_DATA (enabled by default),
Leak_after_array_abstraction (enabled by default), Leak_after_array_abstraction (enabled by default),
Leak_in_footprint (enabled by default), Leak_in_footprint (enabled by default),
Leak_unknown_origin (disabled by default),
MEMORY_LEAK (enabled by default), MEMORY_LEAK (enabled by default),
MISSING_REQUIRED_PROP (enabled by default), MISSING_REQUIRED_PROP (enabled by default),
MIXED_SELF_WEAKSELF (enabled by default), MIXED_SELF_WEAKSELF (enabled by default),

@ -123,6 +123,7 @@ OPTIONS
CROSS_SITE_SCRIPTING (enabled by default), CROSS_SITE_SCRIPTING (enabled by default),
Cannot_star (enabled by default), Cannot_star (enabled by default),
DANGLING_POINTER_DEREFERENCE (disabled by default), DANGLING_POINTER_DEREFERENCE (disabled by default),
DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default),
DEADLOCK (enabled by default), DEADLOCK (enabled by default),
DEAD_STORE (enabled by default), DEAD_STORE (enabled by default),
DEALLOCATE_STACK_VARIABLE (enabled by default), DEALLOCATE_STACK_VARIABLE (enabled by default),
@ -192,6 +193,7 @@ OPTIONS
LOGGING_PRIVATE_DATA (enabled by default), LOGGING_PRIVATE_DATA (enabled by default),
Leak_after_array_abstraction (enabled by default), Leak_after_array_abstraction (enabled by default),
Leak_in_footprint (enabled by default), Leak_in_footprint (enabled by default),
Leak_unknown_origin (disabled by default),
MEMORY_LEAK (enabled by default), MEMORY_LEAK (enabled by default),
MISSING_REQUIRED_PROP (enabled by default), MISSING_REQUIRED_PROP (enabled by default),
MIXED_SELF_WEAKSELF (enabled by default), MIXED_SELF_WEAKSELF (enabled by default),

@ -397,6 +397,7 @@ OPTIONS
CROSS_SITE_SCRIPTING (enabled by default), CROSS_SITE_SCRIPTING (enabled by default),
Cannot_star (enabled by default), Cannot_star (enabled by default),
DANGLING_POINTER_DEREFERENCE (disabled by default), DANGLING_POINTER_DEREFERENCE (disabled by default),
DANGLING_POINTER_DEREFERENCE_MAYBE (disabled by default),
DEADLOCK (enabled by default), DEADLOCK (enabled by default),
DEAD_STORE (enabled by default), DEAD_STORE (enabled by default),
DEALLOCATE_STACK_VARIABLE (enabled by default), DEALLOCATE_STACK_VARIABLE (enabled by default),
@ -466,6 +467,7 @@ OPTIONS
LOGGING_PRIVATE_DATA (enabled by default), LOGGING_PRIVATE_DATA (enabled by default),
Leak_after_array_abstraction (enabled by default), Leak_after_array_abstraction (enabled by default),
Leak_in_footprint (enabled by default), Leak_in_footprint (enabled by default),
Leak_unknown_origin (disabled by default),
MEMORY_LEAK (enabled by default), MEMORY_LEAK (enabled by default),
MISSING_REQUIRED_PROP (enabled by default), MISSING_REQUIRED_PROP (enabled by default),
MIXED_SELF_WEAKSELF (enabled by default), MIXED_SELF_WEAKSELF (enabled by default),

@ -75,7 +75,13 @@ exception Inherently_dangerous_function of Localise.error_desc
exception Internal_error of Localise.error_desc exception Internal_error of Localise.error_desc
exception Leak of bool * (visibility * Localise.error_desc) * bool * PredSymb.resource * L.ocaml_pos exception
Leak of
bool
* (bool (* is it user visible? *) * Localise.error_desc)
* bool
* PredSymb.resource
* L.ocaml_pos
exception Missing_fld of Fieldname.t * L.ocaml_pos exception Missing_fld of Fieldname.t * L.ocaml_pos
@ -208,12 +214,11 @@ let recognize_exception exn =
; visibility= Exn_developer ; visibility= Exn_developer
; severity= Some Info } ; severity= Some Info }
| Dangling_pointer_dereference (user_visible, desc, ocaml_pos) -> | Dangling_pointer_dereference (user_visible, desc, ocaml_pos) ->
let visibility = if user_visible then Exn_user else Exn_developer in let issue_type, visibility =
{ issue_type= IssueType.dangling_pointer_dereference if user_visible then (IssueType.dangling_pointer_dereference, Exn_user)
; description= desc else (IssueType.dangling_pointer_dereference_maybe, Exn_developer)
; ocaml_pos= Some ocaml_pos in
; visibility {issue_type; description= desc; ocaml_pos= Some ocaml_pos; visibility; severity= None}
; severity= None }
| Deallocate_stack_variable desc -> | Deallocate_stack_variable desc ->
{ issue_type= IssueType.deallocate_stack_variable { issue_type= IssueType.deallocate_stack_variable
; description= desc ; description= desc
@ -290,7 +295,7 @@ let recognize_exception exn =
; ocaml_pos= None ; ocaml_pos= None
; visibility= Exn_developer ; visibility= Exn_developer
; severity= None } ; severity= None }
| Leak (fp_part, (exn_vis, error_desc), done_array_abstraction, resource, ocaml_pos) -> | Leak (fp_part, (user_visible, error_desc), done_array_abstraction, resource, ocaml_pos) ->
if done_array_abstraction then if done_array_abstraction then
{ issue_type= IssueType.leak_after_array_abstraction { issue_type= IssueType.leak_after_array_abstraction
; description= error_desc ; description= error_desc
@ -303,6 +308,12 @@ let recognize_exception exn =
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer ; visibility= Exn_developer
; severity= None } ; severity= None }
else if not user_visible then
{ issue_type= IssueType.leak_unknown_origin
; description= error_desc
; ocaml_pos= Some ocaml_pos
; visibility= Exn_developer
; severity= None }
else else
let issue_type = let issue_type =
match resource with match resource with
@ -318,7 +329,7 @@ let recognize_exception exn =
{ issue_type { issue_type
; description= error_desc ; description= error_desc
; ocaml_pos= Some ocaml_pos ; ocaml_pos= Some ocaml_pos
; visibility= exn_vis ; visibility= Exn_user
; severity= None } ; severity= None }
| Missing_fld (fld, ocaml_pos) -> | Missing_fld (fld, ocaml_pos) ->
let desc = Localise.verbatim_desc (Fieldname.to_full_string fld) in let desc = Localise.verbatim_desc (Fieldname.to_full_string fld) in

@ -77,7 +77,12 @@ exception Inherently_dangerous_function of Localise.error_desc
exception Internal_error of Localise.error_desc exception Internal_error of Localise.error_desc
exception exception
Leak of bool * (visibility * Localise.error_desc) * bool * PredSymb.resource * Logging.ocaml_pos Leak of
bool
* (bool (* is it user visible? *) * Localise.error_desc)
* bool
* PredSymb.resource
* Logging.ocaml_pos
exception Missing_fld of Fieldname.t * Logging.ocaml_pos exception Missing_fld of Fieldname.t * Logging.ocaml_pos

@ -293,6 +293,10 @@ let dangling_pointer_dereference =
register_from_string ~enabled:false ~id:"DANGLING_POINTER_DEREFERENCE" Biabduction register_from_string ~enabled:false ~id:"DANGLING_POINTER_DEREFERENCE" Biabduction
let dangling_pointer_dereference_maybe =
register_from_string ~enabled:false ~id:"DANGLING_POINTER_DEREFERENCE_MAYBE" Biabduction
let dead_store = register_from_string ~id:"DEAD_STORE" Liveness let dead_store = register_from_string ~id:"DEAD_STORE" Liveness
let deadlock = register_from_string ~id:"DEADLOCK" Starvation let deadlock = register_from_string ~id:"DEADLOCK" Starvation
@ -492,6 +496,8 @@ let leak_after_array_abstraction =
let leak_in_footprint = register_from_string ~id:"Leak_in_footprint" Biabduction let leak_in_footprint = register_from_string ~id:"Leak_in_footprint" Biabduction
let leak_unknown_origin = register_from_string ~enabled:false ~id:"Leak_unknown_origin" Biabduction
let lock_consistency_violation = register_from_string ~id:"LOCK_CONSISTENCY_VIOLATION" RacerD let lock_consistency_violation = register_from_string ~id:"LOCK_CONSISTENCY_VIOLATION" RacerD
let lockless_violation = register_from_string ~id:"LOCKLESS_VIOLATION" Starvation let lockless_violation = register_from_string ~id:"LOCKLESS_VIOLATION" Starvation

@ -147,6 +147,8 @@ val cross_site_scripting : t
val dangling_pointer_dereference : t val dangling_pointer_dereference : t
val dangling_pointer_dereference_maybe : t
val dead_store : t val dead_store : t
val deadlock : t val deadlock : t
@ -254,6 +256,8 @@ val leak_after_array_abstraction : t
val leak_in_footprint : t val leak_in_footprint : t
val leak_unknown_origin : t
val lockless_violation : t val lockless_violation : t
val lock_consistency_violation : t val lock_consistency_violation : t

@ -524,20 +524,21 @@ let explain_leak tenv hpred prop alloc_att_opt bucket =
L.d_ln () ) ; L.d_ln () ) ;
value_str_from_pvars_vpath [] vpath value_str_from_pvars_vpath [] vpath
in in
let exn_cat, bucket = let is_user_visible, bucket =
(* decide whether Exn_user or Exn_developer *) (* decide whether Exn_user or Exn_developer *)
match resource_opt with match resource_opt with
| Some _ -> | Some _ ->
(* we know it has been allocated *) (* we know it has been allocated *)
(Exceptions.Exn_user, bucket) (true, bucket)
| None -> | None ->
if leak_from_list_abstraction hpred prop && Option.is_some value_str then if leak_from_list_abstraction hpred prop && Option.is_some value_str then
(* we don't know it's been allocated, (* we don't know it's been allocated,
but it's coming from list abstraction and we have a name *) but it's coming from list abstraction and we have a name *)
(Exceptions.Exn_user, bucket) (true, bucket)
else (Exceptions.Exn_developer, Some Mleak_buckets.ml_bucket_unknown_origin) else (false, Some Mleak_buckets.ml_bucket_unknown_origin)
in in
(exn_cat, Localise.desc_leak hpred_typ_opt value_str resource_opt res_action_opt loc bucket) ( is_user_visible
, Localise.desc_leak hpred_typ_opt value_str resource_opt res_action_opt loc bucket )
(** find the dexp, if any, where the given value is stored also return the type of the value if (** find the dexp, if any, where the given value is stored also return the type of the value if

@ -95,7 +95,7 @@ val explain_leak :
-> 'a Prop.t -> 'a Prop.t
-> PredSymb.t option -> PredSymb.t option
-> string option -> string option
-> Exceptions.visibility * Localise.error_desc -> bool (* should the leak be reported to the user? *) * Localise.error_desc
(** Produce a description of a leak by looking at the current state. If the current instruction is a (** Produce a description of a leak by looking at the current state. If the current instruction is a
variable nullify, blame the variable. If it is an abstraction, blame any variable nullify at the variable nullify, blame the variable. If it is an abstraction, blame any variable nullify at the
current node. If there is an alloc attribute, print the function call and line number. *) current node. If there is an alloc attribute, print the function call and line number. *)

Loading…
Cancel
Save