Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting cells: 'basic_string: construction from null is not valid' #1164

Closed
patrickschulz opened this issue Sep 29, 2022 · 6 comments
Closed
Assignees
Milestone

Comments

@patrickschulz
Copy link

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 (#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

@klayoutmatthias
Copy link
Collaborator

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 :(

@patrickschulz
Copy link
Author

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.

@klayoutmatthias
Copy link
Collaborator

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

@klayoutmatthias
Copy link
Collaborator

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

@joamatab
Copy link
Contributor

Any change we could get a new 0.27.11 release with this patch?

I see it on Arch and Debian

#1176

@klayoutmatthias
Copy link
Collaborator

Was released with 0.27.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants