Skip to content

Commit c55b4a5

Browse files
authored
Merge pull request diffblue#1682 from martin-cs/fix/dependence-graph-namespace-lifespan
Avoid crashing when --dependence-graph is used by correcting namespac…
2 parents 1a2c14b + 2801f0f commit c55b4a5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
312312
/// For the task, build the appropriate kind of analyzer
313313
/// Ideally this should be a pure function of options.
314314
/// However at the moment some domains require the goto_model
315-
ai_baset *goto_analyzer_parse_optionst::build_analyzer(const optionst &options)
315+
ai_baset *goto_analyzer_parse_optionst::build_analyzer(
316+
const optionst &options,
317+
const namespacet &ns)
316318
{
317319
ai_baset *domain = nullptr;
318320

@@ -325,7 +327,7 @@ ai_baset *goto_analyzer_parse_optionst::build_analyzer(const optionst &options)
325327
}
326328
else if(options.get_bool_option("dependence-graph"))
327329
{
328-
domain=new dependence_grapht(namespacet(goto_model.symbol_table));
330+
domain=new dependence_grapht(ns);
329331
}
330332
else if(options.get_bool_option("intervals"))
331333
{
@@ -349,7 +351,7 @@ ai_baset *goto_analyzer_parse_optionst::build_analyzer(const optionst &options)
349351
}
350352
else if(options.get_bool_option("dependence-graph"))
351353
{
352-
domain=new dependence_grapht(namespacet(goto_model.symbol_table));
354+
domain=new dependence_grapht(ns);
353355
}
354356
else if(options.get_bool_option("intervals"))
355357
{
@@ -612,7 +614,8 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
612614

613615
// Build analyzer
614616
status() << "Selecting abstract domain" << eom;
615-
std::unique_ptr<ai_baset> analyzer(build_analyzer(options));
617+
namespacet ns(goto_model.symbol_table); // Must live as long as the domain.
618+
std::unique_ptr<ai_baset> analyzer(build_analyzer(options, ns));
616619

617620
if(analyzer == nullptr)
618621
{

src/goto-analyzer/goto_analyzer_parse_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class goto_analyzer_parse_optionst:
168168

169169
virtual int perform_analysis(const optionst &options);
170170

171-
ai_baset *build_analyzer(const optionst &options);
171+
ai_baset *build_analyzer(const optionst &, const namespacet &ns);
172172

173173
void eval_verbosity();
174174

0 commit comments

Comments
 (0)