Skip to content

Crash when deleting a hierarchical PCell library from Python #905

@iqmtestd

Description

@iqmtestd

Hi @klayoutmatthias,

Thanks for making KLayout! It works great with our KQcircuits project to design quantum computers.

We have several libraries of PCells in the above Python package. Everything works fine but I had to disable reloading libraries as it is crashing with KLayout 0.27. By reloading I mean deleting the library and registering it anew.

Specifically, when deleting a library that has PCells that use PCells from the same library we get :
ERROR: ../../../src/db/db/dbLayout.cc,1692,topological_sort ()

This problem is very similar to an earlier bug: #646. Luckily, I could even use the same example code (with small changes) to reproduce the problem. If pcell2 is not using pcell1 then then it works. If I remove the tl_assert from line 1692 then everything is peachy but I'm not certain that this is the right solution...

import pya

class PCell1(pya.PCellDeclarationHelper):

  def produce_impl(self):
    pass

  def display_text_impl(self):
    return "PCell1"

class PCell2(pya.PCellDeclarationHelper):

  def produce_impl(self):
    cell = self.layout.create_cell("PCell1", "PCell1Library", {})
    self.cell.insert(pya.DCellInstArray(cell.cell_index(), pya.DTrans()))

  def display_text_impl(self):
    return "PCell2"

def create_libraries():
  library1 = pya.Library()
  library1.description = "Test library"
  library1.layout().register_pcell("PCell1", PCell1())
  library1.layout().register_pcell("PCell2", PCell2())
  library1.register("PCell1Library")

def reload_libraries():
  mw = pya.MainWindow.instance()
  library1 = pya.Library.library_by_name("PCell1Library")
  library1.delete()
  create_libraries()
  mw.create_layout(1)

def create_pcell():
  cell_view = pya.CellView.active()
  layout = cell_view.layout()
  cell = layout.create_cell("PCell2", "PCell1Library", {})
  cell_view.cell = cell

pya.MainWindow.instance().create_layout(1)
create_libraries()
create_pcell()
reload_libraries()

Best regards,
David

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions