Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yosys-plugin: use-after-delete if unused module removed #366

Open
hzeller opened this issue Jul 15, 2022 · 2 comments
Open

Yosys-plugin: use-after-delete if unused module removed #366

hzeller opened this issue Jul 15, 2022 · 2 comments
Assignees

Comments

@hzeller
Copy link
Collaborator

hzeller commented Jul 15, 2022

Running the plugin with address sanitizer revealed that there are situations that deleted objects are re-used.

I hot-fixed it locally by skipping the deleted values, but I suspect a proper fix would possibly removing it from the container; leaving it up to you.

--- a/systemverilog-plugin/UhdmAst.cc
+++ b/systemverilog-plugin/UhdmAst.cc
@@ -598,6 +598,7 @@ static AST::AstNode *convert_dot(AST::As
 static void setup_current_scope(std::unordered_map<std::string, AST::AstNode *> top_nodes, AST::AstNode *current_top_node)
 {
     for (auto it = top_nodes.begin(); it != top_nodes.end(); it++) {
+        if (!it->second) continue;
         if (it->second->type == AST::AST_PACKAGE) {
             for (auto &o : it->second->children) {
                 // import only parameters
@@ -1408,7 +1409,7 @@ void UhdmAst::process_design()
         }
     }
     // Once we walked everything, unroll that as children of this node
-    for (auto pair : shared.top_nodes) {
+    for (auto &pair : shared.top_nodes) {
         if (!pair.second)
             continue;
         if (!pair.second->get_bool_attribute(UhdmAst::partial())) {
@@ -1424,6 +1425,7 @@ void UhdmAst::process_design()
         } else {
             log_warning("Removing unused module: %s from the design.\n", pair.second->str.c_str());
             delete pair.second;
+            pair.second = nullptr;
         }
     }
 }

We really need chipsalliance/synlig#649 to find these things early.

@hzeller
Copy link
Collaborator Author

hzeller commented Jul 26, 2022

Any update on this one ?

@rkapuscik
Copy link
Contributor

This is being worked on as part of chipsalliance/synlig#913 - I'll try to split that PR to get some of the changes merged faster.

mglb pushed a commit to antmicro/yosys-f4pga-plugins that referenced this issue Apr 3, 2023
…les/yosys-symbiflow-plugins-eaecd87

Bump yosys-symbiflow-plugins from `7fa69f8` to `eaecd87`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants