KLayout / klayout

KLayout Main Sources
http://www.klayout.org
GNU General Public License v3.0
781 stars 199 forks source link

Possible bug report #1693

Open ashkanr65 opened 5 months ago

ashkanr65 commented 5 months ago

Hi, I receive this error on Klayout 0.29.0: Exception code: 0xc0000005 Program Version: KLayout 0.29.0 (2024-03-31 red486a687) AMD64

Backtrace:
0x7ffd73cbbf5a - (klayout_db.dll) +835418
0x7ffd73c7756c - (klayout_db.dll) +554348
0x7ffd73425784 - (klayout_edt.dll) +546692
0x7ffd73426eb4 - (klayout_edt.dll) +552628
0x7ffd75918d63 - (klayout_laybasic.dll) +363875
0x7ffd765e43ab - (Qt5Core.dll) +2966443
0x7ffd76533eca - (Qt5Core.dll) +2244298
0x7ffd7652585b - (Qt5Core.dll) +2185307
0x7ffd72dd7dae - (Qt5Widgets.dll) +32174
0x7ffd7d433b1e - (klayout_lay.dll) +80670
0x7ffd764f8e68 - (Qt5Core.dll) +2002536
0x7ffd76554867 - (Qt5Core.dll) +2377831
0x7ffd76554cf4 - (Qt5Core.dll) +2378996
0x7ffe60968961 - (USER32.dll) +100705
0x7ffe60968421 - (USER32.dll) +99361
0x7ffd7655424b - (Qt5Core.dll) +2376267
0x7ffd8210f505 - (qwindows.dll) +521477
0x7ffd764f7374 - (Qt5Core.dll) +1995636
0x7ffd764ffe65 - (Qt5Core.dll) +2031205
0x7ffd7d43935e - (klayout_lay.dll) +103262
0x7ff7f7d11ad9 - (klayout_app.exe) +6873
0x7ffd78db14a2 - (klayout_rba.dll) +5282
0x7ffd7dcb4e4e - (x64-msvcrt-ruby310.dll) +2117198
0x7ffd7dcbfc6a - (x64-msvcrt-ruby310.dll) +2161770
0x7ffd7dcce364 - (x64-msvcrt-ruby310.dll) +2220900
0x7ffd7dcc0687 - (x64-msvcrt-ruby310.dll) +2164359
0x7ffd7db310fd - (x64-msvcrt-ruby310.dll) +528637
0x7ffd7db34eb5 - (x64-msvcrt-ruby310.dll) +544437
0x7ffd78db8355 - (klayout_rba.dll) +33621
0x7ff7f7d12619 - (klayout_app.exe) +9753
0x7ff7f7d13026 - (klayout_app.exe) +12326
0x7ff7f7d112ee - (klayout_app.exe) +4846
0x7ff7f7d113e6 - (klayout_app.exe) +5094
0x7ffe5ffb257d - (KERNEL32.DLL) +75133
0x7ffe61c8aa48 - (ntdll.dll) +371272

It appears after I refresh my libraries several times.

klayoutmatthias commented 5 months ago

I need more information. Like what kind of libraries you use and what exactly you're doing. Plus I need a test case to debug the issue. This crash dump does not tell at lot.

In case you develop PCell code, I recommend not using the IDE. IDE + PCell execution + Layout work are not a stable combination. There are too many interactions between UI events, IDE breakpoints, Python or Ruby object management and layout editor operation. To fix this, I'd need to separate the IDE into a different process among other things, which is a too big project to start now.

Matthias

ashkanr65 commented 5 months ago

I created a folder named ‘tech’ in the Klayout directory. I placed my Pcells there. While I use VScode to edit my Pcells, I rely on the Klayout IDE to rerun the code. The process involves running the Pcell code first and then executing the library generator code. This error doesn’t occur every time; it’s relatively rare, happening perhaps 1 in 10 instances. Unfortunately, I’m unsure how to reproduce it, as it seems to occur randomly. However, it’s more likely to happen when I place 3 or 4 generated cells into a layout, refresh one cell, and then run the library generator.

klayoutmatthias commented 5 months ago

I think I understand.

The problem with re-running a script inside KLayout is basically the following: a script will usually redefine classes that are potentially connected to life layout objects. This is like cutting off the branch of a tree you sit on. As we are crossing the script/C++ boundary with their fundamentally different object lifetime management concepts, this interaction gets very difficult to manage.

The situation is much different between Python and Ruby because Ruby uses a different memory management model, and the problem may show up differently in different Python versions.

I am trying to prevent these problems when I come across one during debugging, but there is an inherent instability in the whole scheme and such debugging sessions are very time consuming. The trace of events can usually only be tracked inside a debugger and a stack trace alone is of little help. I have not had serious issues myself recently, but I am not doing frequent PCell development.

You can try mitigating the issue somewhat by turning off the debugger in the IDE.

I'm afraid, the only safe option as of now is to restart KLayout every time you try out a new PCell implementation.

Matthias

klayoutmatthias commented 2 months ago

I am trying to improve the situation continuously (right now, in fact), but I am afraid, this ticket will never really be solved.

Can I close this ticket?

Thanks,

Matthias

ashkanr65 commented 2 months ago

Yes you can. BTW, thank you for your all hardworks