-
Notifications
You must be signed in to change notification settings - Fork 210
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
ERROR: src/db/db/dbPCellHeader.cc,137,v != m_variant_map.end () #1782
Comments
Hi Lukas, the message basically means that there is a second incarnation of the same PCell (same parameters) in the library. This should not happen as the You may be able to spot this case by looking at the raw cell names in the layout and checking if there are two raw cells for the same parameter set. One possible scenario which may trigger the problem is re-registration of a PCell. So if a library for some reason re-registers a PCell while there are PCell instances already present for the original PCell, this error could happen upon cleanup of the layout. There is no log one could easily enable to detect this problem. The code responsible for the above scenario is in I have to investigate this scenario. Actually I think this may be responsible for some issues we find when developing PCells inside the application. However, this is only a hypothesis. It may be something else as well. Matthias |
Thanks Matthias. My script only loads the library once, and I don't re-register it. But indeed, I issue ly.create_cell many times, and there are repeats with the same parameters. The curious thing is that my first loop generates 17 cells, and those 17 are repeated in a second loop which generates 66 cells. Yet, I receive the error message 5 times when closing. I'll keep an eye out for this, and see if it comes up again, ideally in a smaller project. |
Hi Lukas, Thanks for the explanation. Could you elaborate a little on what you mean by "those 17 are repeated in a second loop"? Does that mean a (deep) copy or just instances of that cell? Or something else? For now I was able to reproduce the problem with a code that deliberately re-registers a PCell:
Which gives:
The crash is due to an uncaught exception - the error happens in the Python shutdown code which is outside exception handling. But being able to reproduce it, does not mean I know what is going on :( I can basically make re-registration a valid operation and turn the assertion into a warning. That should prevent the crash. That might not be the real cure however. Matthias |
Hi Matthias,
|
Hi Matthias, I discovered the source of the error. We discovered this when two PCell calls resulted in the same output, despite having different inputs. One PCell call had a parameter with a numerical value, while the other had the same parameter being a float('nan'). The PCell was expecting a self.TypeDouble, and Python is happy with 'nan' and 'inf'. I was passing a PCell parameter: Inside the PCell, I would check. But I notice that you can't compare:
So I think the PCell wrapper wasn't handling nan correctly. I replace 'nan' with 1e6 and check for that instead, and now the errors are gone. I also checked for infinity, float('inf'), and it also produces the same errors. So inf is also not handled properly. Perhaps you could add a check in PCell declaration helper for self.TypeDouble, to disallow 'nan' and 'inf'? Unless there is a way to enable 'nan'? thank you |
Hi Lukas, thanks for this analysis. I guess that pretty well explains the weird effects. I never looked into the compare behavior of NaN in C++, but al least, strict weak ordering - as mandated by the STL sets and maps I use - is probably not the given. I will try to debug the problem. It is probably easy to fix. Best regards, Matthias |
I tried to reproduce the problem with "nan", but without much success. I can confirm however, that different parameter sets give the same cell and maybe that is producing issues once the So I think that is enough for a tentative fix. BTW: I noticed, that the GDS file written with the "nan" parameter is broken - reading it errors out with
So NaN isn't a good idea in general. Basically, there is not much type checking between PCell client script and PCell code: if you pass parameters by script, you can essentially use "None" as a value of "TypeDouble" and receive "None" inside you code. However, when you edit such a layout, you will see a value of "0" instead of "None". All that is needed is some "optional" attribute for the PCell parameters and there could be an empty edit box for "None" in that case. Best regards, Matthias |
Got it. Here is my code to reproduce it:
And again I get the Abort signal because of the uncaught exception. Anyway, there is enough material for debugging. I think the NaN's and inf's need special care. And I will also address the re-registration issue as this is possibly responsible for program crashes during PCell development. Thanks for your help and for reporting the issue. Best regards, Matthias |
This patch establishes "nan", "inf" and "-inf" as valid values for tl::Variant, so corresponding PCell parameters can be serialized and are properly managed.
Hi @klayoutmatthias
I am receiving this error after running a long script that generates a large layout. I am running the script using an external python environment, using "import pya". The error fortunately occurs after I save my layout, upon completion of the script. I have seen it come and go for the past few hours. I'm sorry I don't have a minimum example to share that reproduces this error. I am hoping you may have some suggestion on how to debug. The script includes calling PCells that I have created.
ERROR: src/db/db/dbPCellHeader.cc,137,v != m_variant_map.end ()
thank you
The text was updated successfully, but these errors were encountered: