From: David Malcolm Date: Wed, 23 Sep 2020 15:18:43 +0000 (-0400) Subject: analyzer: fix member call on null seen with ubsan [PR97178] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f65ebb5210e2fded0f7b339219685f4480124f0c;p=gcc.git analyzer: fix member call on null seen with ubsan [PR97178] gcc/analyzer/ChangeLog: PR analyzer/97178 * engine.cc (impl_run_checkers): Update for change to ext_state ctor. * program-state.cc (selftest::test_sm_state_map): Pass an engine instance to ext_state ctor. (selftest::test_program_state_1): Likewise. (selftest::test_program_state_2): Likewise. (selftest::test_program_state_merging): Likewise. (selftest::test_program_state_merging_2): Likewise. * program-state.h (extrinsic_state::extrinsic_state): Remove NULL default value for "eng" param. --- diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 437429798f2..b36c1988406 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -4464,7 +4464,7 @@ impl_run_checkers (logger *logger) } /* Extrinsic state shared by nodes in the graph. */ - const extrinsic_state ext_state (checkers, logger, &eng); + const extrinsic_state ext_state (checkers, &eng, logger); const analysis_plan plan (sg, logger); diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 83a6e5b081e..188fec02418 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -1140,7 +1140,8 @@ test_sm_state_map () state_machine *sm = make_malloc_state_machine (NULL); auto_delete_vec checkers; checkers.safe_push (sm); - extrinsic_state ext_state (checkers); + engine eng; + extrinsic_state ext_state (checkers, &eng); state_machine::state_t start = sm->get_start_state (); /* Test setting states on svalue_id instances directly. */ @@ -1272,7 +1273,7 @@ test_program_state_1 () checkers.safe_push (sm); engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); region_model_manager *mgr = eng.get_model_manager (); program_state s (ext_state); region_model *model = s.m_region_model; @@ -1301,7 +1302,7 @@ test_program_state_2 () auto_delete_vec checkers; engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); program_state s (ext_state); region_model *model = s.m_region_model; @@ -1324,7 +1325,7 @@ test_program_state_merging () auto_delete_vec checkers; checkers.safe_push (make_malloc_state_machine (NULL)); engine eng; - extrinsic_state ext_state (checkers, NULL, &eng); + extrinsic_state ext_state (checkers, &eng); region_model_manager *mgr = eng.get_model_manager (); program_state s0 (ext_state); @@ -1389,7 +1390,8 @@ test_program_state_merging_2 () program_point point (program_point::origin ()); auto_delete_vec checkers; checkers.safe_push (make_signal_state_machine (NULL)); - extrinsic_state ext_state (checkers); + engine eng; + extrinsic_state ext_state (checkers, &eng); const state_machine::state test_state_0 ("test state 0", 0); const state_machine::state test_state_1 ("test state 1", 1); diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index a52fbeb2e3e..094d2562656 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -29,8 +29,8 @@ class extrinsic_state { public: extrinsic_state (auto_delete_vec &checkers, - logger *logger = NULL, - engine *eng = NULL) + engine *eng, + logger *logger = NULL) : m_checkers (checkers), m_logger (logger), m_engine (eng) { }