Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  

    Hi all, I am using KLayout 24.9 (2016-11-27 r3488).

    Trying to call set_property in a loop on a large number of instances (> 30000) failed for me with the following line:

    Internal error: c:\klayout\0.24\src\tlReuseVector.h:255 mp_v->is_used (m_n) was not true in Instance::cell in Action::triggered
    

    Could this be caused by an out-of-memory situation, or do I have another problem in my script?

    If it is of interest, I can try to create a script (by removing anything unrelated) to reproduce the error, but I thought I ask first whether this is a known problem.

    Thanks, Chris

    • CommentAuthorMatthias
    • CommentTimeMar 7th 2017 edited
     

    Hi Chris,

    this message basically says that KLayout can't find an object it likes to iterate over. This can happen if you modify the objects "substantially" while iterating over them. Setting a property is a "substantial" modification since it may turn a property-less instance into one with properties and vice versa.

    What you experience as "objects" (i.e. Instance) are basically pointers into the internal data structures of KLayout. I am trying to make them look like objects, but still some use scenarios are not supported. Providing some code may help me to improve the implementation.

    In general, my recommendation is not to modify objects while iterating over them. It always safer to collect the objects you want to modify first and then modify them. Like this:

    cell = ... # some cell
    
    instances_to_modify = []
    cell.each_inst do |inst|
      instances_to_modify << inst
    end
    
    instances_to_modify.each do |inst|
      inst.set_property(42, "meaning of life")
    end
    

    Some methods and properties are safe to use/modify within loops. For instance objects these are (no warranty):

    • Target cell: cell=, cell_index=
    • Transformation: trans=, cplx_trans= and transformation methods transform, transform_into
    • Array properties: a=, b=, na=, nb=
    • change_pcell_parameter, change_pcell_parameters
    • convert_to_static
    • delete
    • parent_cell= (with restrictions)

    Other properties and methods are not necessarily safe to use while iterating. At least no currently.

    Matthias

  2.  

    Hi Matthias,

    Thank you very much for this information, I had indeed used a single loop to go through and modify the list of instances. Separating the loop into a "collect" loop followed by another "modify" loop as you suggested resolved the issue.

    Also thanks for the list of methods intended to support in-place modification of objects, I'll try to avoid modifying objects via other methods in the same loop in the future.

    In any case, it is good to know what the error message means "in layman's terms" so that I come across it again, at least I know what to watch out for :-)

    Thanks again for making such a powerful tool available to the rest of us!

    Chris

    • CommentAuthorMatthias
    • CommentTimeMar 13th 2017
     

    Hi Chris,

    I wish I could give a better message in this case :-)

    But that's actually a deeply buried assertion which is a general hint that something is inconsistent.

    Matthias