mirror of
https://github.com/Z3Prover/z3
synced 2025-06-08 15:13:23 +00:00
restore most global muxes as heap-allocated to avoid crashes with hard-kills like ctrl-c
This commit is contained in:
parent
d17248821a
commit
c21f0c2f00
8 changed files with 55 additions and 49 deletions
|
@ -21,7 +21,7 @@ Notes:
|
|||
#include "util/trace.h"
|
||||
#include "util/mutex.h"
|
||||
|
||||
static mutex gparams_mux;
|
||||
static DECLARE_MUTEX(gparams_mux);
|
||||
|
||||
extern void gparams_register_modules();
|
||||
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
}
|
||||
|
||||
void reset() {
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
m_params.reset();
|
||||
for (auto & kv : m_module_params) {
|
||||
dealloc(kv.m_value);
|
||||
|
@ -329,7 +329,7 @@ public:
|
|||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
|
@ -381,7 +381,7 @@ public:
|
|||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
|
@ -428,7 +428,7 @@ public:
|
|||
params_ref result;
|
||||
params_ref * ps = nullptr;
|
||||
{
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
if (m_module_params.find(module_name, ps)) {
|
||||
result.copy(*ps);
|
||||
}
|
||||
|
@ -447,30 +447,28 @@ public:
|
|||
// -----------------------------------------------
|
||||
|
||||
void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) {
|
||||
{
|
||||
lock_guard lock(gparams_mux);
|
||||
out << "Global parameters\n";
|
||||
get_param_descrs().display(out, indent + 4, smt2_style, include_descr);
|
||||
lock_guard lock(*gparams_mux);
|
||||
out << "Global parameters\n";
|
||||
get_param_descrs().display(out, indent + 4, smt2_style, include_descr);
|
||||
out << "\n";
|
||||
if (!smt2_style) {
|
||||
out << "To set a module parameter, use <module-name>.<parameter-name>=value\n";
|
||||
out << "Example: pp.decimal=true\n";
|
||||
out << "\n";
|
||||
if (!smt2_style) {
|
||||
out << "To set a module parameter, use <module-name>.<parameter-name>=value\n";
|
||||
out << "Example: pp.decimal=true\n";
|
||||
out << "\n";
|
||||
}
|
||||
for (auto & kv : get_module_param_descrs()) {
|
||||
out << "[module] " << kv.m_key;
|
||||
char const * descr = nullptr;
|
||||
if (get_module_descrs().find(kv.m_key, descr)) {
|
||||
out << ", description: " << descr;
|
||||
}
|
||||
out << "\n";
|
||||
kv.m_value->display(out, indent + 4, smt2_style, include_descr);
|
||||
}
|
||||
for (auto & kv : get_module_param_descrs()) {
|
||||
out << "[module] " << kv.m_key;
|
||||
char const * descr = nullptr;
|
||||
if (get_module_descrs().find(kv.m_key, descr)) {
|
||||
out << ", description: " << descr;
|
||||
}
|
||||
out << "\n";
|
||||
kv.m_value->display(out, indent + 4, smt2_style, include_descr);
|
||||
}
|
||||
}
|
||||
|
||||
void display_modules(std::ostream & out) {
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
for (auto & kv : get_module_param_descrs()) {
|
||||
out << "[module] " << kv.m_key;
|
||||
char const * descr = nullptr;
|
||||
|
@ -484,7 +482,7 @@ public:
|
|||
void display_module(std::ostream & out, symbol const & module_name) {
|
||||
bool error = false;
|
||||
std::string error_msg;
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
param_descrs * d = nullptr;
|
||||
if (!get_module_param_descrs().find(module_name, d)) {
|
||||
|
@ -513,7 +511,7 @@ public:
|
|||
bool error = false;
|
||||
std::string error_msg;
|
||||
{
|
||||
lock_guard lock(gparams_mux);
|
||||
lock_guard lock(*gparams_mux);
|
||||
try {
|
||||
symbol m, p;
|
||||
normalize(name, m, p);
|
||||
|
@ -636,10 +634,8 @@ void gparams::init() {
|
|||
|
||||
void gparams::finalize() {
|
||||
TRACE("gparams", tout << "gparams::finalize()\n";);
|
||||
if (g_imp != nullptr) {
|
||||
dealloc(g_imp);
|
||||
g_imp = nullptr;
|
||||
}
|
||||
dealloc(g_imp);
|
||||
delete gparams_mux;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue