3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-08 23:23:23 +00:00
memory leaks
This commit is contained in:
Nikolaj Bjorner 2021-05-19 12:42:38 -07:00
parent abe3ef2382
commit ec034679ce
7 changed files with 26 additions and 18 deletions

View file

@ -46,16 +46,14 @@ extern "C" {
gparams::reset(); gparams::reset();
env_params::updt_params(); env_params::updt_params();
} }
static std::string g_Z3_global_param_get_buffer;
Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) { Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) {
memory::initialize(UINT_MAX); memory::initialize(UINT_MAX);
LOG_Z3_global_param_get(param_id, param_value); LOG_Z3_global_param_get(param_id, param_value);
*param_value = nullptr; *param_value = nullptr;
try { try {
g_Z3_global_param_get_buffer = gparams::get_value(param_id); gparams::g_buffer() = gparams::get_value(param_id);
*param_value = g_Z3_global_param_get_buffer.c_str(); *param_value = gparams::g_buffer().c_str();
return true; return true;
} }
catch (z3_exception & ex) { catch (z3_exception & ex) {

View file

@ -39,7 +39,7 @@ public:
}; };
class var_register { class var_register {
svector<ext_var_info> m_local_to_external; vector<ext_var_info> m_local_to_external;
std::unordered_map<unsigned, unsigned> m_external_to_local; std::unordered_map<unsigned, unsigned> m_external_to_local;
unsigned m_locals_mask; unsigned m_locals_mask;
unsigned m_locals_mask_inverted; unsigned m_locals_mask_inverted;

View file

@ -34,6 +34,7 @@ namespace euf {
m.dec_ref(inf->a); m.dec_ref(inf->a);
m.dec_ref(inf->b); m.dec_ref(inf->b);
m.dec_ref(inf->c); m.dec_ref(inf->c);
dealloc(inf);
} }
m_table.reset(); m_table.reset();
m_queue = nullptr; m_queue = nullptr;

View file

@ -46,7 +46,6 @@ Revision History:
typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_MPS, IN_DRAT } input_kind; typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_LP, IN_Z3_LOG, IN_MPS, IN_DRAT } input_kind;
static std::string g_aux_input_file;
static char const * g_input_file = nullptr; static char const * g_input_file = nullptr;
static char const * g_drat_input_file = nullptr; static char const * g_drat_input_file = nullptr;
static bool g_standard_input = false; static bool g_standard_input = false;
@ -124,7 +123,7 @@ void display_usage() {
std::cout << "Use 'z3 -p' for the complete list of global and module parameters.\n"; std::cout << "Use 'z3 -p' for the complete list of global and module parameters.\n";
} }
static void parse_cmd_line_args(int argc, char ** argv) { static void parse_cmd_line_args(std::string& input_file, int argc, char ** argv) {
long timeout = 0; long timeout = 0;
int i = 1; int i = 1;
char * eq_pos = nullptr; char * eq_pos = nullptr;
@ -134,19 +133,18 @@ static void parse_cmd_line_args(int argc, char ** argv) {
if (arg[0] == '-' && arg[1] == '-' && arg[2] == 0) { if (arg[0] == '-' && arg[1] == '-' && arg[2] == 0) {
// Little hack used to read files with strange names such as -foo.smt2 // Little hack used to read files with strange names such as -foo.smt2
// z3 -- -foo.smt2 // z3 -- -foo.smt2
i++;
g_aux_input_file = "";
for (; i < argc; i++) {
g_aux_input_file += argv[i];
if (i < argc - 1)
g_aux_input_file += " ";
}
if (g_input_file) { if (g_input_file) {
warning_msg("input file was already specified."); warning_msg("input file was already specified.");
break;
} }
else { i++;
g_input_file = g_aux_input_file.c_str(); input_file = "";
for (; i < argc; i++) {
input_file += argv[i];
if (i < argc - 1)
input_file += " ";
} }
g_input_file = input_file.c_str();
break; break;
} }
@ -321,11 +319,12 @@ static void parse_cmd_line_args(int argc, char ** argv) {
int STD_CALL main(int argc, char ** argv) { int STD_CALL main(int argc, char ** argv) {
try{ try {
unsigned return_value = 0; unsigned return_value = 0;
memory::initialize(0); memory::initialize(0);
memory::exit_when_out_of_memory(true, "ERROR: out of memory"); memory::exit_when_out_of_memory(true, "ERROR: out of memory");
parse_cmd_line_args(argc, argv); std::string input_file;
parse_cmd_line_args(input_file, argc, argv);
env_params::updt_params(); env_params::updt_params();
if (g_input_file && g_standard_input) { if (g_input_file && g_standard_input) {

View file

@ -137,6 +137,7 @@ struct gparams::imp {
smap<params_ref* > m_module_params; smap<params_ref* > m_module_params;
params_ref m_params; params_ref m_params;
region m_region; region m_region;
std::string m_buffer;
void check_registered() { void check_registered() {
if (m_modules_registered) if (m_modules_registered)
@ -651,3 +652,8 @@ void gparams::finalize() {
dealloc(g_imp); dealloc(g_imp);
DEALLOC_MUTEX(gparams_mux); DEALLOC_MUTEX(gparams_mux);
} }
std::string& gparams::g_buffer() {
SASSERT(g_imp);
return g_imp->m_buffer;
}

View file

@ -26,6 +26,9 @@ class gparams {
public: public:
typedef default_exception exception; typedef default_exception exception;
static std::string& g_buffer();
/** /**
\brief Reset all global and module parameters. \brief Reset all global and module parameters.
*/ */

View file

@ -153,4 +153,5 @@ void scoped_timer::finalize() {
} }
} }
num_workers = 0; num_workers = 0;
available_workers.clear();
} }