klayout
klayout copied to clipboard
Deleting cells: 'basic_string: construction from null is not valid'
Whenever I'm deleting any cells, I get this message, which is problematic since I can not delete a bunch of cells simultaneously. There is a similar issue (https://github.com/KLayout/klayout/issues/1099), but in my case this does not have to do anything with any PDK or pcells. I can reproduce this with a fresh config, I use the (default) technology and inserted an empty cell in the toplevel layout. When I delete that, I get this error.
My setup: arch linux (kernel 5.19.11) klayout 0.27.11 ruby 2.7 qt 5.15
Kind regards, Patrick
Thanks for this report
However I seem not to be able to reproduce it (0.27.12, Ubuntu-22). Here is what I did:
KLAYOUT_HOME=/dev/null klayout -e
(KLAYOUT_HOME=/dev/null forces default config).
Then:
- File/New Layout
- Right click on cell list -> New Cell, call it "A"
- Select cell A, right click on cell list -> Delete Cell
There is no error message :(
Thanks for your quick reply. I tried it again exactly like you, unfortunately I can reproduce this even then... Is there a way to see where this error is coming from? I've tried setting a higher debug level but the result is not really helpful to me. I looked through it but nothing caught my eye. I'm happy to dig deeper, but I need some pointer on how to do that.
The message is pretty generic - it says that a std::string has been created from a null const char *.
I can see the error on an archlinux docker image with klayout from the package repo. I'll try to debug the problem.
Matthias
Okay, found the problem ... praise Docker! :)
Here is a lecture for C++ users on things to be careful with.
Line 848 of dbLayout.cc is this:
848 manager ()->queue (this, new NewRemoveCellOp (*c, cell_name (*c), true /*remove*/, take_cell (*c)));
So what happens is that take_cell(*c) removes the cell from the cell stack, cell_name(*c) reads the name of the the cell indicated by *c. C++ is basically free to evaluate the argument expressions in any order. So on my systems (Ubuntu with gcc 11.2 and clang, Windows, CentOS etc.), apparently the compiler evaluates the arguments in the given order. I.e. cell_name before take_cell and everything is fine. On archlinux (gcc 12.2) the order appears to be the other way and take_cell removes the cell before cell_name tries to read it. That causes this exception.
So the fix is simply to make sure cell_name is called before take_cell.
Thanks for reporting this issue.
Matthias
Any change we could get a new 0.27.11 release with this patch?
I see it on Arch and Debian
https://github.com/KLayout/klayout/issues/1176
Was released with 0.27.12