3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-12 02:04:44 +00:00

Fix Crashes with GCC 15 #5088

When building `WITH_PYTHON`, where a global list of modules is maintained, deleting a module also erases the entry in said global list.  This can lead to memory corruption if the global list is destructed before the module.
Using `on_shutdown()` instead means the module destructor is explicitly called before the global list can be destructed, preventing the issue.
Also add a comment to `Pass::~Pass()` to suggest the same for future passes that might try to use that (and see this commit in the blame if they need a reason why).
This commit is contained in:
Krystine Sherwin 2025-05-10 09:59:13 +12:00
parent c4af97c1c4
commit af75dce660
No known key found for this signature in database
2 changed files with 2 additions and 1 deletions

View file

@ -29,6 +29,7 @@ struct Pass
{
std::string pass_name, short_help;
Pass(std::string name, std::string short_help = "** document me **");
// Prefer overriding 'Pass::on_shutdown()' if possible
virtual ~Pass();
virtual void help();

View file

@ -28,7 +28,7 @@ std::vector<RTLIL::Design*> pushed_designs;
struct DesignPass : public Pass {
DesignPass() : Pass("design", "save, restore and reset current design") { }
~DesignPass() override {
void on_shutdown() override {
for (auto &it : saved_designs)
delete it.second;
saved_designs.clear();