From 54d46d1bcf3d25a878cf3ad1de3db226b0aaa528 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 27 Apr 2026 02:55:02 -0700 Subject: [PATCH 1/4] fixes use-after-free bug in report level lookup cache --- src/sysc/scc/report.cpp | 4 ++-- src/sysc/scc/report.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sysc/scc/report.cpp b/src/sysc/scc/report.cpp index 7ed8ba77a..4a859e4aa 100644 --- a/src/sysc/scc/report.cpp +++ b/src/sysc/scc/report.cpp @@ -75,7 +75,7 @@ struct char_hash { }; static class { std::unordered_map table; - std::vector cache; + std::deque cache; std::mutex mtx; public: @@ -89,7 +89,7 @@ static class { } void insert(char const* key, sc_core::sc_verbosity verb) { std::lock_guard lock(mtx); - cache.push_back(key); + cache.emplace_back(key); table.insert({cache.back().c_str(), verb}); } void clear() { diff --git a/src/sysc/scc/report.h b/src/sysc/scc/report.h index 61af3846f..1a0367a0d 100644 --- a/src/sysc/scc/report.h +++ b/src/sysc/scc/report.h @@ -76,6 +76,8 @@ writing. By default spdlog logs asyncronously to keep the performance impact low */ //! the name of the CCI property to attach to modules to control logging of this module #define SCC_LOG_LEVEL_PARAM_NAME "log_level" +#define SCC_LOG_LEVEL_PARAM_NAME_LEN 9 + /** \ingroup scc-sysc * @{ */ From 73b1c19f097d9215d09f72ab584ee0322ed11f20 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 27 Apr 2026 02:55:57 -0700 Subject: [PATCH 2/4] improves reporting of unused cci preset values --- src/sysc/scc/configurer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sysc/scc/configurer.cpp b/src/sysc/scc/configurer.cpp index 5cbc0f513..bf8c7a8a2 100644 --- a/src/sysc/scc/configurer.cpp +++ b/src/sysc/scc/configurer.cpp @@ -643,13 +643,18 @@ void mirror_sc_attributes(configurer::broker_t& broker, configurer::cci_param_cl } bool cci_name_ignore(std::pair const& preset_value) { - std::string ending(SCC_LOG_LEVEL_PARAM_NAME); auto& name = preset_value.first; - if(name.length() >= ending.length()) { - return (0 == name.compare(name.length() - ending.length(), ending.length(), ending)); - } else { + if(name.length() < SCC_LOG_LEVEL_PARAM_NAME_LEN) // name is to short to hold the log level return false; - } + size_t dot = name.find_last_of("."); + if (dot == std::string::npos) + return name == SCC_LOG_LEVEL_PARAM_NAME; + if(name.substr(dot, name.size() - dot).compare(SCC_LOG_LEVEL_PARAM_NAME)!=0) + // the parameter name is not SCC_LOG_LEVEL_PARAM_NAME + return false; + std::string module_name = name.substr(0, dot); + // ignore the SCC_LOG_LEVEL_PARAM_NAME preset if module exists + return sc_core::sc_find_object(name.c_str())!=nullptr; } } // namespace #ifdef HAS_YAMPCPP From 47a5ba2c0913f22b3d6596a203bba73703e9e558 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 27 Apr 2026 03:38:14 -0700 Subject: [PATCH 3/4] applies clang-format --- src/sysc/scc/configurable_tracer.cpp | 10 ++++++++-- src/sysc/scc/configurer.cpp | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/sysc/scc/configurable_tracer.cpp b/src/sysc/scc/configurable_tracer.cpp index da56b966c..77b72473a 100644 --- a/src/sysc/scc/configurable_tracer.cpp +++ b/src/sysc/scc/configurable_tracer.cpp @@ -16,7 +16,8 @@ #include "configurable_tracer.h" #include "traceable.h" - +#include +#include using namespace sc_core; using namespace scc; @@ -54,14 +55,19 @@ void configurable_tracer::descend(const sc_core::sc_object* obj, bool trace) { descend(o, trace); return; } else if(kind == "sc_module") { + auto module_name = obj->name(); auto trace_enable = get_trace_enabled(obj, default_trace_enable_handle.get_cci_value().get()); + printf(fmt::format("{}: {}\n", module_name, trace_enable).c_str()); if(trace_enable) obj->trace(trf); for(auto o : obj->get_child_objects()) descend(o, trace_enable); } else if(kind == "sc_variable") { - if(trace && (types_to_trace & trace_types::VARIABLES) == trace_types::VARIABLES) + if(trace && (types_to_trace & trace_types::VARIABLES) == trace_types::VARIABLES) { + printf(fmt::format("tracing {}\n", obj->name()).c_str()); obj->trace(trf); + } else + printf(fmt::format("not tracing {}\n", obj->name()).c_str()); } else if(kind == "sc_signal" || kind == "sc_clock" || kind == "sc_buffer" || kind == "sc_signal_rv") { if(trace && (types_to_trace & trace_types::SIGNALS) == trace_types::SIGNALS) try_trace(trf, obj, types_to_trace); diff --git a/src/sysc/scc/configurer.cpp b/src/sysc/scc/configurer.cpp index bf8c7a8a2..7d1aa87e6 100644 --- a/src/sysc/scc/configurer.cpp +++ b/src/sysc/scc/configurer.cpp @@ -647,14 +647,14 @@ bool cci_name_ignore(std::pair const& preset_value) if(name.length() < SCC_LOG_LEVEL_PARAM_NAME_LEN) // name is to short to hold the log level return false; size_t dot = name.find_last_of("."); - if (dot == std::string::npos) + if(dot == std::string::npos) return name == SCC_LOG_LEVEL_PARAM_NAME; - if(name.substr(dot, name.size() - dot).compare(SCC_LOG_LEVEL_PARAM_NAME)!=0) + if(name.substr(dot, name.size() - dot).compare(SCC_LOG_LEVEL_PARAM_NAME) != 0) // the parameter name is not SCC_LOG_LEVEL_PARAM_NAME return false; std::string module_name = name.substr(0, dot); // ignore the SCC_LOG_LEVEL_PARAM_NAME preset if module exists - return sc_core::sc_find_object(name.c_str())!=nullptr; + return sc_core::sc_find_object(name.c_str()) != nullptr; } } // namespace #ifdef HAS_YAMPCPP From 16e4d562d50615c6840b7c8e51df8ff2bd9a5a8e Mon Sep 17 00:00:00 2001 From: Lucas Klemmer <3308172+LucasKl@users.noreply.github.com> Date: Tue, 28 Apr 2026 08:17:10 +0000 Subject: [PATCH 4/4] Clean up --- src/sysc/scc/configurable_tracer.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/sysc/scc/configurable_tracer.cpp b/src/sysc/scc/configurable_tracer.cpp index 77b72473a..4be06ef82 100644 --- a/src/sysc/scc/configurable_tracer.cpp +++ b/src/sysc/scc/configurable_tracer.cpp @@ -57,17 +57,13 @@ void configurable_tracer::descend(const sc_core::sc_object* obj, bool trace) { } else if(kind == "sc_module") { auto module_name = obj->name(); auto trace_enable = get_trace_enabled(obj, default_trace_enable_handle.get_cci_value().get()); - printf(fmt::format("{}: {}\n", module_name, trace_enable).c_str()); if(trace_enable) obj->trace(trf); for(auto o : obj->get_child_objects()) descend(o, trace_enable); } else if(kind == "sc_variable") { - if(trace && (types_to_trace & trace_types::VARIABLES) == trace_types::VARIABLES) { - printf(fmt::format("tracing {}\n", obj->name()).c_str()); + if(trace && (types_to_trace & trace_types::VARIABLES) == trace_types::VARIABLES) obj->trace(trf); - } else - printf(fmt::format("not tracing {}\n", obj->name()).c_str()); } else if(kind == "sc_signal" || kind == "sc_clock" || kind == "sc_buffer" || kind == "sc_signal_rv") { if(trace && (types_to_trace & trace_types::SIGNALS) == trace_types::SIGNALS) try_trace(trf, obj, types_to_trace);