Skip to content

LayoutMetaInfo serialization/deserialization bugged #1397

@sebastian-goeldi

Description

@sebastian-goeldi

Hi Matthias,

Sorry to already open a new issue about meta infos ;).

Since the bugfix has been pushed into 0.28.9(2?), I dug out the metainfo branch of kfactory and noticed that the read
will fail with a bad alloc. I think the issue is with the serialization/deserialization not being correct. My guess lies on the deserialization.

Small test to reproduce below:

test.py
import klayout.db as kdb

l = kdb.Layout()
c = l.create_cell("test_cell")
li = kdb.LayerInfo(1, 0)
t = kdb.Trans.R180
c.add_meta_info(kdb.LayoutMetaInfo("kfactory:li", li, None, True))
c.add_meta_info(kdb.LayoutMetaInfo("kfactory:t", t, None, True))
l.write("test.gds")

l2 = kdb.Layout()
l2.read("test.gds")
c2 = l2.cell("test_cell")
li = c2.meta_info("kfactory:li").value
print(li.layer, li.datatype)
t = c2.meta_info("kfactory:t").value
print(t)

this produces

9701763 -1076411715
* 0,9701763

which is obviously not what I wanted it to be ;).

when converting to txt version of gds (as always thanks to strm2gdstxt), it looks like this:

test.gds.txt
HEADER 600 
BGNLIB 6/12/2023 11:18:12 6/12/2023 11:18:12 
LIBNAME LIB
UNITS 0.001 1e-09 

BGNSTR 6/12/2023 11:18:12 6/12/2023 11:18:12 
STRNAME $$$CONTEXT_INFO$$$
SREF 
SNAME test_cell
XY 0: 0
PROPATTR 2 
PROPVALUE META('kfactory:t')=[trans:r180 0,0]
PROPATTR 1 
PROPVALUE META('kfactory:li')=[layer:1/0]
PROPATTR 0 
PROPVALUE CELL=test_cell
ENDEL 
ENDSTR 

BGNSTR 6/12/2023 11:18:12 6/12/2023 11:18:12 
STRNAME test_cell
ENDSTR 
ENDLIB 

Looking at that data, I suspect it's correctly written by when deserializing, there is an error.
I hope this is reproducible on your end.

As a workaround for now, I will just rely on manaully do to_s()/from_s().

Best,
Sebastian

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions