mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Merge pull request #3865 from dragonmux/fix/rtlil-teardown-segfault
Fix: RTLIL teardown segfault
This commit is contained in:
commit
a43e26e3e9
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
YOSYS_NAMESPACE_BEGIN
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
bool RTLIL::IdString::destruct_guard_ok = false;
|
||||||
RTLIL::IdString::destruct_guard_t RTLIL::IdString::destruct_guard;
|
RTLIL::IdString::destruct_guard_t RTLIL::IdString::destruct_guard;
|
||||||
std::vector<char*> RTLIL::IdString::global_id_storage_;
|
std::vector<char*> RTLIL::IdString::global_id_storage_;
|
||||||
dict<char*, int, hash_cstr_ops> RTLIL::IdString::global_id_index_;
|
dict<char*, int, hash_cstr_ops> RTLIL::IdString::global_id_index_;
|
||||||
|
|
|
@ -85,10 +85,10 @@ namespace RTLIL
|
||||||
|
|
||||||
// the global id string cache
|
// the global id string cache
|
||||||
|
|
||||||
|
static bool destruct_guard_ok; // POD, will be initialized to zero
|
||||||
static struct destruct_guard_t {
|
static struct destruct_guard_t {
|
||||||
bool ok; // POD, will be initialized to zero
|
destruct_guard_t() { destruct_guard_ok = true; }
|
||||||
destruct_guard_t() { ok = true; }
|
~destruct_guard_t() { destruct_guard_ok = false; }
|
||||||
~destruct_guard_t() { ok = false; }
|
|
||||||
} destruct_guard;
|
} destruct_guard;
|
||||||
|
|
||||||
static std::vector<char*> global_id_storage_;
|
static std::vector<char*> global_id_storage_;
|
||||||
|
@ -147,7 +147,7 @@ namespace RTLIL
|
||||||
|
|
||||||
static int get_reference(const char *p)
|
static int get_reference(const char *p)
|
||||||
{
|
{
|
||||||
log_assert(destruct_guard.ok);
|
log_assert(destruct_guard_ok);
|
||||||
|
|
||||||
if (!p[0])
|
if (!p[0])
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -225,7 +225,7 @@ namespace RTLIL
|
||||||
{
|
{
|
||||||
// put_reference() may be called from destructors after the destructor of
|
// put_reference() may be called from destructors after the destructor of
|
||||||
// global_refcount_storage_ has been run. in this case we simply do nothing.
|
// global_refcount_storage_ has been run. in this case we simply do nothing.
|
||||||
if (!destruct_guard.ok || !idx)
|
if (!destruct_guard_ok || !idx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef YOSYS_XTRACE_GET_PUT
|
#ifdef YOSYS_XTRACE_GET_PUT
|
||||||
|
@ -443,13 +443,13 @@ namespace RTLIL
|
||||||
static inline std::string encode_filename(const std::string &filename)
|
static inline std::string encode_filename(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::stringstream val;
|
std::stringstream val;
|
||||||
if (!std::any_of(filename.begin(), filename.end(), [](char c) {
|
if (!std::any_of(filename.begin(), filename.end(), [](char c) {
|
||||||
return static_cast<unsigned char>(c) < 33 || static_cast<unsigned char>(c) > 126;
|
return static_cast<unsigned char>(c) < 33 || static_cast<unsigned char>(c) > 126;
|
||||||
})) return filename;
|
})) return filename;
|
||||||
for (unsigned char const c : filename) {
|
for (unsigned char const c : filename) {
|
||||||
if (c < 33 || c > 126)
|
if (c < 33 || c > 126)
|
||||||
val << stringf("$%02x", c);
|
val << stringf("$%02x", c);
|
||||||
else
|
else
|
||||||
val << c;
|
val << c;
|
||||||
}
|
}
|
||||||
return val.str();
|
return val.str();
|
||||||
|
|
Loading…
Reference in a new issue