Klayout crashes when running "iter.next() "

Hi Mathias,
How to file a bug report?

I hfound a bug when running "iter.next() "

Here is the tracing code:

Signal number: 11
Address: 0x2b
Program Version: KLayout 0.26.2 (2020-03-09 rLatestSourcePackage)

Backtrace:
/usr/lib/klayout/libklayout_lay.so.0 +0x2c45f7 lay::enable_signal_handler_gui(bool) [??:?]
/lib/x86_64-linux-gnu/libc.so.6 +0x41950 killpg [??:?]
/usr/lib/klayout/libklayout_db.so.0 +0x48c209 db::TouchingInstanceIteratorTraits::init(db::instance_iterator) const [??:?]
/usr/lib/klayout/libklayout_db.so.0 +0x49daae db::instance_iterator::operator++() [??:?]
/usr/lib/klayout/libklayout_db.so.0 +0x58d7f0 db::RecursiveShapeIterator::next_shape(db::RecursiveShapeReceiver
) const [??:?]
/usr/lib/klayout/libklayout_pya.so.0 +0x541ed pya::PythonModule::init(char const*, _object*) [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0xa3ea7 _Py_CheckFunctionResult [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0xa4d3b _PyObject_MakeTpCall [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x7fe64 _PyEval_EvalFrameDefault [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x76ede _PyEval_EvalFrameDefault [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x74de3 ?? [??:0]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x7fbdd _PyEval_EvalFrameDefault [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x7734a _PyEval_EvalFrameDefault [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x17eb1f _PyEval_EvalCodeWithName [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x17eec2 PyEval_EvalCodeEx [??:?]
/lib/x86_64-linux-gnu/libpython3.8.so.1.0 +0x17d6df PyEval_EvalCode [??:?]
/usr/lib/klayout/libklayout_pya.so.0 +0x354e7 pya::PythonInterpreter::eval_string(char const*, char const*, int, int) [??:?]
/usr/lib/klayout/libklayout_lym.so.0 +0x328c7 lym::Macro::run() const [??:?]
/usr/lib/klayout/libklayout_lay.so.0 +0x17d2e3 lay::LogFile::~LogFile() [??:?]
/usr/lib/klayout/libklayout_lay.so.0 +0x17d571 lay::LogFile::~LogFile() [??:?]
/usr/lib/klayout/libklayout_lay.so.0 +0x2d5aad lay::LogViewerDialog::~LogViewerDialog() [??:?]
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x2e1320 QObject::setProperty(char const*, QVariant const&) [??:?]
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x259ec6 QAbstractButton::clicked(bool) [??:?]
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x25a88e QAbstractButton::setIconSize(QSize const&) [??:?]
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x25c143
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x25c325 _ZN15QAbstractButton17mouseReleaseEventEP11QMouseEvent
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x34e59e _ZN11QToolButton17mouseReleaseEventEP11QMouseEvent
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x1ac30e _ZN7QWidget5eventEP6QEvent
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x16b013 _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x170841 _ZN12QApplication6notifyEP7QObjectP6QEvent
/usr/lib/klayout/libklayout_lay.so.0 +0x11941a _ZN3lay14GuiApplication6notifyEP7QObjectP6QEvent
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x2ab1ca _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x16f73a _ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Ebb
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x1c4f32
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x1c7d8e
/lib/x86_64-linux-gnu/libQt5Widgets.so.5 +0x16b013 _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
/usr/lib/klayout/libklayout_lay.so.0 +0x11941a _ZN3lay14GuiApplication6notifyEP7QObjectP6QEvent
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x2ab1ca _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
/lib/x86_64-linux-gnu/libQt5Gui.so.5 +0x13e48b _ZN22QGuiApplicationPrivate17processMouseEventEPN29QWindowSystemInterfacePrivate10MouseEventE
/lib/x86_64-linux-gnu/libQt5Gui.so.5 +0x1142bb _ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 +0x6835e
/lib/x86_64-linux-gnu/libglib-2.0.so.0 +0x534eb g_main_context_dispatch
/lib/x86_64-linux-gnu/libglib-2.0.so.0 +0x53798
/lib/x86_64-linux-gnu/libglib-2.0.so.0 +0x53863 g_main_context_iteration
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x302843 _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x2a9a4b _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE
/lib/x86_64-linux-gnu/libQt5Core.so.5 +0x2b1fc6 _ZN16QCoreApplication4execEv
/usr/lib/klayout/libklayout_lay.so.0 +0x11aa50 _ZN3lay14GuiApplication4execEv
/usr/lib/klayout/libklayout_lay.so.0 +0x11bbcd _ZN3lay15ApplicationBase3runEv
/usr/lib/klayout/klayout +0x4569
/usr/lib/klayout/libklayout_rba.so.0 +0x21104
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0x216177
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0x20a546
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0x21a9d0
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0x22084b rb_vm_exec
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0xa1a07
/lib/x86_64-linux-gnu/libruby-2.7.so.2.7 +0xa5ffc ruby_run_node
/usr/lib/klayout/libklayout_rba.so.0 +0x21484 _ZN3rba15RubyInterpreter10initializeERiPPcPFiS1_S3_E
/usr/lib/klayout/klayout +0x3ce4
/lib/x86_64-linux-gnu/libc.so.6 +0x28cb2 __libc_start_main
/usr/lib/klayout/klayout +0x3e5e

The script I was using is here:
(Btw: it does not crashes when the database is small with less than 15 elements. It crashes when the box overlaps more than 15 polygons)

                  iter = cell.begin_shapes_rec_overlapping(layer, box)
                  while not iter.at_end() :
                          polygone = iter.shape().polygon.transformed(iter.trans())      
                          trans = iter.trans()
                          bbox = polygone.bbox()
                          #print(str(bbox.inside(bbox)))


                         #print("{} != {}\n".format(int(last_x),int(bbox.left)))
                          print("Die type: {} [ col {} , row {} ] @ {}, {}, agngle: {}, is_mirror: {} \n"\
                               .format(str( iter.cell().name ),col, row,str(bbox.left/Dbu), str(bbox.bottom/Dbu), str( trans.angle), str( trans.is_mirror()) )   )

                          charcell = dsl.chars.create_char( layout, str(row), 45, Dbu)
                          if str( trans.is_mirror()) == "True" :
                                  insert_cells(cell,charcell.name, 1.0, 0.0 , True, bbox.left/Dbu, (bbox.bottom/Dbu)+25.0,  1, 1, 0, 0  )
                          else:
                                   insert_cells(cell,charcell.name, 1.0, 0.0 , False, bbox.left/Dbu, bbox.bottom/Dbu,  1, 1, 0, 0  )

                          iter.next()

Thank you in advance and best regards
Giovanni

Comments

  • Hi Matthias

    Now is not crashing anymore :-)

    I found one solution (Must state to which cell the iter is defined):

    cell.iter = cell.begin_shapes_rec_overlapping(layer, box)
    .......
    cell.iter.next()

    Thanks
    Giovanni

  • Hi Giovanni,

    I don't think is actually the solution.

    I don't know what "insert_cells" does. But I assume it alters the state of the cells you're iterating over. It' s recommended not to modify the hierarchy while doing a recursive iteration. This will mess with the state of the iterator and make it unstable.

    You should rather store bbox and trans in a list and run the cell generation in a second step by iterating over this list rather the inside the shape iteration loop.

    Regards,

    Matthias

Sign In or Register to comment.