From d1935941a609e276d2b6c5ee761106760518ee5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Tue, 19 Jan 2021 01:29:09 -0800 Subject: [PATCH] [control][hotfix] Don't fail when not all exit nodes are prune nodes Summary: Clang front-end is confused about exceptional CF. For the following program ``` void throw_positive(int b) { if (b > 0) { throw std::length_error("error"); } } void foo( std::vector traceTokens){ if (traceTokens.size() < 13) { throw std::invalid_argument("Exception!"); // 1 } for (int i = 13; i < traceTokens.size(); ++i) { try { throw_positive(traceTokens[i].size()); } catch (std::range_error& msg) { throw(1); // 2 } try { throw_positive(traceTokens[7].size()); } catch (std::range_error& msg) { throw (9); // 3 } } } ``` Here, infer thinks that there are edges from 1->2 and 1-> 3. This should not be the case. This in turn makes control analysis think that there is a back edge from 3->2 and violates the assertion that the exit node (3 in this case) must be a prune node... Replacing assertion with internal error for now until I fix the clang frontend. Reviewed By: skcho Differential Revision: D25947376 fbshipit-source-id: 5c6529647 --- infer/src/checkers/control.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infer/src/checkers/control.ml b/infer/src/checkers/control.ml index 205f7fd94..c0634f6e1 100644 --- a/infer/src/checkers/control.ml +++ b/infer/src/checkers/control.ml @@ -164,7 +164,8 @@ module TransferFunctionsControlDeps (CFG : ProcCfg.S) = struct astate' ) | _ -> (* Exit node must be a prune node *) - assert (not (ExitNodeToLoopHeads.mem node exit_map)) ; + if ExitNodeToLoopHeads.mem node exit_map then + L.internal_error "Exit node must be a prune node!" ; astate'