diff --git a/infer/src/concurrency/starvationDomain.ml b/infer/src/concurrency/starvationDomain.ml index 9a573e033..eafe314e5 100644 --- a/infer/src/concurrency/starvationDomain.ml +++ b/infer/src/concurrency/starvationDomain.ml @@ -128,15 +128,21 @@ module Lock = struct let is_recursive tenv lock = - let is_class_and_recursive_lock = function - | {Typ.desc= Tptr ({desc= Tstruct name}, _)} | {desc= Tstruct name} -> - ConcurrencyModels.is_recursive_lock_type name - | typ -> - L.debug Analysis Verbose "Asked if non-struct type %a is a recursive lock type.@." - (Typ.pp_full Pp.text) typ ; - true - in - get_typ tenv lock |> Option.exists ~f:is_class_and_recursive_lock + (* The "default" below is returned when we don't have enough information. We choose + the default depending on the language, since most Java locks are recursive and most C++ locks + are not. *) + match get_typ tenv lock with + | Some {Typ.desc= Tptr ({desc= Tstruct name}, _)} | Some {desc= Tstruct name} -> + ConcurrencyModels.is_recursive_lock_type name + | Some typ -> + (* weird type passed as a lock, return default *) + L.debug Analysis Verbose "Asked if non-struct type %a is a recursive lock type.@\n" + (Typ.pp_full Pp.text) typ ; + Language.curr_language_is Java + | None -> + (* could not find type definition, return default *) + L.debug Analysis Verbose "Could not resolve type for lock %a.@\n" pp lock ; + Language.curr_language_is Java end module AccessExpressionDomain = struct