diff --git a/src/db/db/dbCommonReader.cc b/src/db/db/dbCommonReader.cc index b1becdcfb..e52b94c69 100644 --- a/src/db/db/dbCommonReader.cc +++ b/src/db/db/dbCommonReader.cc @@ -240,7 +240,7 @@ CommonReaderBase::cell_for_instance (db::Layout &layout, const std::string &cn) } void -CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) const +CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) { const db::Cell &src_cell = layout.cell (src_cell_index); db::Cell &target_cell = layout.cell (target_cell_index); @@ -284,7 +284,7 @@ CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cel } void -CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) const +CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) { const db::Cell &src_cell = layout.cell (src_cell_index); db::Cell &target_cell = layout.cell (target_cell_index); @@ -297,20 +297,21 @@ CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_ind } // replace all instances of the new cell with the original one - layout.replace_instances_of (src_cell.cell_index (), target_cell.cell_index ()); + layout.replace_instances_of (src_cell_index, target_cell_index); // merge meta info if (with_meta) { - auto ib = layout.begin_meta (src_cell.cell_index ()); - auto ie = layout.end_meta (src_cell.cell_index ()); + auto ib = layout.begin_meta (src_cell_index); + auto ie = layout.end_meta (src_cell_index); for (auto i = ib; i != ie; ++i) { - layout.add_meta_info (target_cell.cell_index (), i->first, i->second); + layout.add_meta_info (target_cell_index, i->first, i->second); } } - layout.clear_meta (src_cell.cell_index ()); + layout.clear_meta (src_cell_index); // finally delete the new cell - layout.delete_cell (src_cell.cell_index ()); + m_temp_cells.erase (src_cell_index); + layout.delete_cell (src_cell_index); } void diff --git a/src/db/db/dbCommonReader.h b/src/db/db/dbCommonReader.h index 1a7dafcdf..065c5eb6c 100644 --- a/src/db/db/dbCommonReader.h +++ b/src/db/db/dbCommonReader.h @@ -242,12 +242,12 @@ class DB_PUBLIC CommonReaderBase /** * @brief Merge (and delete) the src_cell into target_cell */ - void merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) const; + void merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances); /** * @brief Merge (and delete) the src_cell into target_cell without instances */ - void merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) const; + void merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta); /** * @brief Gets the layer name map diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc index 02d1f8a3c..7f906dcd8 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc @@ -679,3 +679,24 @@ TEST(DuplicateCellname) EXPECT_EQ (ex.msg ().find ("Same cell name TOP, but different IDs: 3 and 0 (position=1070, cell=)"), size_t (0)); } } + +TEST(BlendCrash) +{ + db::Manager m (false); + db::Layout layout (&m); + + { + tl::InputStream file (tl::testdata () + "/oasis/blend_crash1.oas"); + db::OASISReader reader (file); + reader.read (layout); + } + + { + tl::InputStream file (tl::testdata () + "/oasis/blend_crash2.oas"); + db::OASISReader reader (file); + reader.read (layout); + } + + std::string fn_au (tl::testdata () + "/oasis/blend_crash_au.gds.gz"); + db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); +} diff --git a/testdata/oasis/blend_crash1.oas b/testdata/oasis/blend_crash1.oas new file mode 100644 index 000000000..1d86e551f Binary files /dev/null and b/testdata/oasis/blend_crash1.oas differ diff --git a/testdata/oasis/blend_crash2.oas b/testdata/oasis/blend_crash2.oas new file mode 100644 index 000000000..ccd436483 Binary files /dev/null and b/testdata/oasis/blend_crash2.oas differ diff --git a/testdata/oasis/blend_crash_au.gds.gz b/testdata/oasis/blend_crash_au.gds.gz new file mode 100644 index 000000000..5118f4399 Binary files /dev/null and b/testdata/oasis/blend_crash_au.gds.gz differ