new python release has issues
Closed this issue · 14 comments
RuntimeError: Cannot write layer numbers larger than 65535 to GDS2 streams, writing cell 'Unnamed_0' in Cell.write
https://github.com/gdsfactory/gdsfactory/actions/runs/10189276913/job/28186995933
and segfaults
https://github.com/gdsfactory/gdsfactory/actions/runs/10189276906/job/28186996591
You only have two bytes to store layer number and two for datatype, so this number is correct.
I suspect this is related to this from the release:
Enhancement: GDS2 writer now observes limitations of the file format
and raises more errors on value over- or underflows. This should specifically avoid issues writing certain large arrays which are legal inside KLayout, but illegal in GDS2.
Ouch. Segfault is always bad. I cannot quickly see the offending line of code. Can you make a minimum viable piece of code I can look at?
I will take a look.
Looks like the GDS layer problem got solved with 7f1f57fb42d67305f375fd788c3ae17dcb35f552.
The segfault reproduces for me.
I checked in the debugger, but all I see it is happening inside freetype:
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007fff8cc3bc0a in FT_Outline_Get_Orientation () from /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so
(gdb) bt
#0 0x00007fff8cc3bc0a in FT_Outline_Get_Orientation ()
from /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so
#1 0x00007ffff5876e2e in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#2 0x00007ffff5873493 in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#3 0x00007ffff54b03e9 in _call_function_pointer (argtypecount=<optimized out>, argcount=1, resmem=0x7fffffff7f60, restype=<optimized out>,
atypes=<optimized out>, avalues=<optimized out>, pProc=0x7fff8cc3bbd0 <FT_Outline_Get_Orientation>, flags=4353)
at ./Modules/_ctypes/callproc.c:916
#4 _ctypes_callproc (pProc=<optimized out>, argtuple=<optimized out>, flags=<optimized out>, argtypes=<optimized out>, restype=<optimized out>,
checker=<optimized out>) at ./Modules/_ctypes/callproc.c:1262
#5 0x00007ffff54afa00 in PyCFuncPtr_call (self=<optimized out>, inargs=<optimized out>, kwds=0x0) at ./Modules/_ctypes/_ctypes.c:4221
#6 0x00005555556a552b in _PyObject_MakeTpCall (tstate=0x555555b59de0,
callable=<_FuncPtr(__name__='FT_Outline_Get_Orientation') at remote 0x7fff8d068400>, args=<optimized out>, nargs=<optimized out>,
keywords=0x0) at ../Objects/call.c:215
#7 0x000055555569f1c7 in call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, trace_info=0x7fffffff82d0,
tstate=<optimized out>) at ../Python/ceval.c:5890
...
I also ran valgrind to find if there is anything suspicious with KLayout, but without effect:
(testenv) matthias@beast:~/versuche/gdsfactory$ valgrind python3 -m pytest --cov=gdsfactory
==2745490== Memcheck, a memory error detector
==2745490== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2745490== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==2745490== Command: python3 -m pytest --cov=gdsfactory
==2745490==
==2745490== Invalid read of size 8
==2745490== at 0x40286A0: strncmp (strcmp.S:170)
==2745490== by 0x400668D: is_dst (dl-load.c:216)
==2745490== by 0x400810E: _dl_dst_count (dl-load.c:253)
==2745490== by 0x400810E: expand_dynamic_string_token (dl-load.c:395)
==2745490== by 0x40082B7: fillin_rpath.isra.0 (dl-load.c:483)
==2745490== by 0x4008602: decompose_rpath (dl-load.c:654)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== Address 0x603eee1 is 1 bytes inside a block of size 8 alloc'd
==2745490== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2745490== by 0x40271DF: malloc (rtld-malloc.h:56)
==2745490== by 0x40271DF: strdup (strdup.c:42)
==2745490== by 0x4008594: decompose_rpath (dl-load.c:629)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400E34D: _dl_open (dl-open.c:883)
==2745490==
==2745490== Invalid read of size 8
==2745490== at 0x40286A8: strncmp (strcmp.S:172)
==2745490== by 0x400668D: is_dst (dl-load.c:216)
==2745490== by 0x400810E: _dl_dst_count (dl-load.c:253)
==2745490== by 0x400810E: expand_dynamic_string_token (dl-load.c:395)
==2745490== by 0x40082B7: fillin_rpath.isra.0 (dl-load.c:483)
==2745490== by 0x4008602: decompose_rpath (dl-load.c:654)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== Address 0x603eee9 is 1 bytes after a block of size 8 alloc'd
==2745490== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2745490== by 0x40271DF: malloc (rtld-malloc.h:56)
==2745490== by 0x40271DF: strdup (strdup.c:42)
==2745490== by 0x4008594: decompose_rpath (dl-load.c:629)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400E34D: _dl_open (dl-open.c:883)
==2745490==
==2745490== Invalid read of size 8
==2745490== at 0x40286A0: strncmp (strcmp.S:170)
==2745490== by 0x400668D: is_dst (dl-load.c:216)
==2745490== by 0x4007F79: _dl_dst_substitute (dl-load.c:295)
==2745490== by 0x40082B7: fillin_rpath.isra.0 (dl-load.c:483)
==2745490== by 0x4008602: decompose_rpath (dl-load.c:654)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== Address 0x603eee1 is 1 bytes inside a block of size 8 alloc'd
==2745490== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2745490== by 0x40271DF: malloc (rtld-malloc.h:56)
==2745490== by 0x40271DF: strdup (strdup.c:42)
==2745490== by 0x4008594: decompose_rpath (dl-load.c:629)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400E34D: _dl_open (dl-open.c:883)
==2745490==
==2745490== Invalid read of size 8
==2745490== at 0x40286A8: strncmp (strcmp.S:172)
==2745490== by 0x400668D: is_dst (dl-load.c:216)
==2745490== by 0x4007F79: _dl_dst_substitute (dl-load.c:295)
==2745490== by 0x40082B7: fillin_rpath.isra.0 (dl-load.c:483)
==2745490== by 0x4008602: decompose_rpath (dl-load.c:654)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== Address 0x603eee9 is 1 bytes after a block of size 8 alloc'd
==2745490== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2745490== by 0x40271DF: malloc (rtld-malloc.h:56)
==2745490== by 0x40271DF: strdup (strdup.c:42)
==2745490== by 0x4008594: decompose_rpath (dl-load.c:629)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:696)
==2745490== by 0x400A8C8: cache_rpath (dl-load.c:677)
==2745490== by 0x400A8C8: _dl_map_object (dl-load.c:2117)
==2745490== by 0x4003494: openaux (dl-deps.c:64)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x4003C7B: _dl_map_object_deps (dl-deps.c:248)
==2745490== by 0x400EA0E: dl_open_worker_begin (dl-open.c:592)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400DF99: dl_open_worker (dl-open.c:782)
==2745490== by 0x4B20A97: _dl_catch_exception (dl-error-skeleton.c:208)
==2745490== by 0x400E34D: _dl_open (dl-open.c:883)
==2745490==
=============================================================== test session starts ===============================================================
platform linux -- Python 3.10.12, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/matthias/versuche/gdsfactory
configfile: pyproject.toml
testpaths: gdsfactory, tests
plugins: cov-5.0.0, regressions-2.5.0, datadir-1.5.0
collected 919 items
gdsfactory/components/spiral_heater.py . [ 0%]
gdsfactory/components/splitter_tree.py .. [ 0%]
gdsfactory/components/straight_heater_metal.py . [ 0%]
gdsfactory/name.py . [ 0%]
gdsfactory/samples/06_remapping_layers.py . [ 0%]
gdsfactory/samples/13_component_netlist.py . [ 0%]
gdsfactory/samples/14_component_connectivity.py . [ 0%]
gdsfactory/samples/15_component_sequence1.py . [ 0%]
gdsfactory/samples/16_component_sequence2.py . [ 1%]
gdsfactory/samples/17_ports.py . [ 1%]
gdsfactory/samples/21_add_fiber_array.py . [ 1%]
gdsfactory/samples/pdk/test_fab_c.py ..... [ 1%]
gdsfactory/technology/layer_views.py . [ 1%]
tests/components/test_components.py ....................................................................................................... [ 13%]
.........................................................................==2745490== Conditional jump or move depends on uninitialised value(s)
==2745490== at 0x7303BC04: FT_Outline_Get_Orientation (in /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so)
==2745490== by 0x93C9E2D: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x93C6492: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x8FC43E8: UnknownInlinedFun (callproc.c:916)
==2745490== by 0x8FC43E8: _ctypes_callproc.cold (callproc.c:1262)
==2745490== by 0x8FC39FF: PyCFuncPtr_call.cold (_ctypes.c:4221)
==2745490== by 0x25952A: _PyObject_MakeTpCall (call.c:215)
==2745490== by 0x2531C6: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x2531C6: _PyEval_EvalFrameDefault (ceval.c:4181)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:114)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:123)
==2745490== by 0x30CA41: trace_call_function.lto_priv.0 (ceval.c:5870)
==2745490== by 0x252671: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x252671: _PyEval_EvalFrameDefault (ceval.c:4213)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:267)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:290)
==2745490== by 0x271F01: PyObject_Call (call.c:317)
==2745490==
==2745490== Use of uninitialised value of size 8
==2745490== at 0x7303BC0A: FT_Outline_Get_Orientation (in /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so)
==2745490== by 0x93C9E2D: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x93C6492: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x8FC43E8: UnknownInlinedFun (callproc.c:916)
==2745490== by 0x8FC43E8: _ctypes_callproc.cold (callproc.c:1262)
==2745490== by 0x8FC39FF: PyCFuncPtr_call.cold (_ctypes.c:4221)
==2745490== by 0x25952A: _PyObject_MakeTpCall (call.c:215)
==2745490== by 0x2531C6: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x2531C6: _PyEval_EvalFrameDefault (ceval.c:4181)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:114)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:123)
==2745490== by 0x30CA41: trace_call_function.lto_priv.0 (ceval.c:5870)
==2745490== by 0x252671: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x252671: _PyEval_EvalFrameDefault (ceval.c:4213)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:267)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:290)
==2745490== by 0x271F01: PyObject_Call (call.c:317)
==2745490==
==2745490== Invalid read of size 2
==2745490== at 0x7303BC0A: FT_Outline_Get_Orientation (in /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so)
==2745490== by 0x93C9E2D: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x93C6492: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
==2745490== by 0x8FC43E8: UnknownInlinedFun (callproc.c:916)
==2745490== by 0x8FC43E8: _ctypes_callproc.cold (callproc.c:1262)
==2745490== by 0x8FC39FF: PyCFuncPtr_call.cold (_ctypes.c:4221)
==2745490== by 0x25952A: _PyObject_MakeTpCall (call.c:215)
==2745490== by 0x2531C6: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x2531C6: _PyEval_EvalFrameDefault (ceval.c:4181)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:114)
==2745490== by 0x30CA41: UnknownInlinedFun (abstract.h:123)
==2745490== by 0x30CA41: trace_call_function.lto_priv.0 (ceval.c:5870)
==2745490== by 0x252671: UnknownInlinedFun (ceval.c:5890)
==2745490== by 0x252671: _PyEval_EvalFrameDefault (ceval.c:4213)
==2745490== by 0x2636AB: UnknownInlinedFun (pycore_ceval.h:46)
==2745490== by 0x2636AB: UnknownInlinedFun (ceval.c:5067)
==2745490== by 0x2636AB: _PyFunction_Vectorcall (call.c:342)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:267)
==2745490== by 0x271F01: UnknownInlinedFun (call.c:290)
==2745490== by 0x271F01: PyObject_Call (call.c:317)
==2745490== Address 0x3 is not stack'd, malloc'd or (recently) free'd
==2745490==
Fatal Python error: Segmentation fault
Thread 0x0000000040226640 (most recent call first):
File "/usr/lib/python3.10/multiprocessing/connection.py", line 379 in _recv
File "/usr/lib/python3.10/multiprocessing/connection.py", line 414 in _recv_bytes
File "/usr/lib/python3.10/multiprocessing/connection.py", line 216 in recv_bytes
File "/usr/lib/python3.10/multiprocessing/queues.py", line 365 in get
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/loguru/_handler.py", line 300 in _queued_writer
File "/usr/lib/python3.10/threading.py", line 953 in run
File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap
Current thread 0x0000000004bd6780 (most recent call first):
File "/home/matthias/versuche/gdsfactory/gdsfactory/font.py", line 151 in _get_glyph
File "/home/matthias/versuche/gdsfactory/gdsfactory/components/text_freetype.py", line 87 in text_freetype
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/kfactory/kcell.py", line 3267 in wrapped_cell
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/cachetools/__init__.py", line 741 in wrapper
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/loguru/_logger.py", line 1277 in catch_wrapper
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/kfactory/kcell.py", line 3400 in wrapper_autocell
File "/home/matthias/versuche/gdsfactory/tests/components/test_components.py", line 31 in test_gds
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/python.py", line 159 in pytest_pyfunc_call
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/python.py", line 1627 in runtest
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 242 in <lambda>
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 341 in from_call
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 241 in call_and_report
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 132 in runtestprotocol
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/main.py", line 362 in pytest_runtestloop
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/main.py", line 337 in _main
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/main.py", line 283 in wrap_session
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103 in _multicall
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120 in _hookexec
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513 in __call__
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 175 in main
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 201 in console_main
File "/home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/pytest/__main__.py", line 9 in <module>
File "/usr/lib/python3.10/runpy.py", line 86 in _run_code
File "/usr/lib/python3.10/runpy.py", line 196 in _run_module_as_main
Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, ruamel.yaml.clib._ruamel_yaml, _ruamel_yaml, zmq.backend.cython._zmq, tornado.speedups, scipy._lib._ccallback_c, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.linalg._propack._spropack, scipy.sparse.linalg._propack._dpropack, scipy.sparse.linalg._propack._cpropack, scipy.sparse.linalg._propack._zpropack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.special._ellip_harm_2, scipy.optimize._group_columns, scipy._lib.messagestream, scipy.optimize._trlib._trlib, scipy.optimize._lbfgsb, _moduleTNC, scipy.optimize._moduleTNC, scipy.optimize._cobyla, scipy.optimize._slsqp, scipy.optimize._minpack, scipy.optimize._lsq.givens_elimination, scipy.optimize._zeros, scipy.optimize._highs.cython.src._highs_wrapper, scipy.optimize._highs._highs_wrapper, scipy.optimize._highs.cython.src._highs_constants, scipy.optimize._highs._highs_constants, scipy.linalg._interpolative, scipy.optimize._bglu_dense, scipy.optimize._lsap, scipy.spatial._ckdtree, scipy.spatial._qhull, scipy.spatial._voronoi, scipy.spatial._distance_wrap, scipy.spatial._hausdorff, scipy.spatial.transform._rotation, scipy.optimize._direct, rpack._core, yaml._yaml, markupsafe._speedups, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pandas._libs.ops, pandas._libs.hashing, pandas._libs.arrays, pandas._libs.tslib, pandas._libs.sparse, pandas._libs.internals, pandas._libs.indexing, pandas._libs.index, pandas._libs.writers, pandas._libs.join, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.json, pandas._libs.parsers, pandas._libs.testing, shapely.lib, shapely._geos, shapely._geometry_helpers, PIL._imaging, kiwisolver._cext, scipy.interpolate._fitpack, scipy.interpolate._dfitpack, scipy.interpolate._bspl, scipy.interpolate._ppoly, scipy.interpolate.interpnd, scipy.interpolate._rbfinterp_pythran, scipy.interpolate._rgi_cython, psutil._psutil_linux, psutil._psutil_posix, scipy.ndimage._nd_image, _ni_label, scipy.ndimage._ni_label, scipy.integrate._odepack, scipy.integrate._quadpack, scipy.integrate._vode, scipy.integrate._dop, scipy.integrate._lsoda (total: 139)
==2745490==
==2745490== Process terminating with default action of signal 11 (SIGSEGV)
==2745490== at 0x4A429FC: __pthread_kill_implementation (pthread_kill.c:44)
==2745490== by 0x4A429FC: __pthread_kill_internal (pthread_kill.c:78)
==2745490== by 0x4A429FC: pthread_kill@@GLIBC_2.34 (pthread_kill.c:89)
==2745490== by 0x49EE475: raise (raise.c:26)
==2745490== by 0x49EE51F: ??? (in /usr/lib/x86_64-linux-gnu/libc.so.6)
==2745490== by 0x7303BC09: FT_Outline_Get_Orientation (in /home/matthias/versuche/gdsfactory/testenv/lib/python3.10/site-packages/freetype/libfreetype.so)
==2745490==
==2745490== HEAP SUMMARY:
==2745490== in use at exit: 112,181,084 bytes in 621,636 blocks
==2745490== total heap usage: 11,510,031 allocs, 10,888,395 frees, 3,737,180,947 bytes allocated
==2745490==
==2745490== LEAK SUMMARY:
==2745490== definitely lost: 160 bytes in 3 blocks
==2745490== indirectly lost: 0 bytes in 0 blocks
==2745490== possibly lost: 5,222,022 bytes in 17,017 blocks
==2745490== still reachable: 106,958,902 bytes in 604,616 blocks
==2745490== of which reachable via heuristic:
==2745490== stdstring : 7,905,899 bytes in 91,266 blocks
==2745490== suppressed: 0 bytes in 0 blocks
==2745490== Rerun with --leak-check=full to see details of leaked memory
==2745490==
==2745490== Use --track-origins=yes to see where uninitialised values come from
==2745490== For lists of detected and suppressed errors, rerun with: -s
==2745490== ERROR SUMMARY: 11 errors from 7 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
Usually, valgrind would report anything bad that KLayout does before it eventually create a problem somewhere else.
I see the "Conditional jump or move depends on uninitialised value(s)" in FT_Outline_Get_Orientation
which may explain the problem. Yet I kind of doubt it is fully on account of freetype. Maybe there is some interference?
im still getting errors on the latest klayout
Using klayout 0.29.4 this works perfectly
import gdsfactory as gf
c = gf.components.straight(length=10, layer=(1, 0))
c.write_gds(with_metadata=False)
However using kayout 0.29.5 I get errors
RuntimeError Traceback (most recent call last)
File ~/demo/hi.py:4
2 import gdsfactory as gf
3 c = gf.components.straight(length=10, layer=(1, 0))
----> 4 c.write_gds(with_metadata=False)
File ~/c/pdks/gdsfactory/gdsfactory/component.py:841, in ComponentBase.write_gds(self, gdspath, gdsdir, sa
ve_options, with_metadata, **kwargs)
839 for k in kwargs:
840 warnings.warn(f"{k} is deprecated", stacklevel=2)
--> 841 self.write(filename=gdspath, save_options=save_options)
842 return pathlib.Path(gdspath)
File ~/c/kfactory/src/kfactory/kcell.py:1562, in KCell.write(self, filename, save_options, convert_externa
l_cells, set_meta_data)
1559 kc = self.kcl[kci]
1560 kc.insert_vinsts()
-> 1562 self._kdb_cell.write(str(filename), save_options)
RuntimeError: Cannot write layer numbers larger than 65535 to GDS2 streams, writing cell 'straight_L10_N2_
CSstrip_L1_0' in Cell.write
Hmm ...
import klayout
print(klayout.__version__)
import gdsfactory as gf
c = gf.components.straight(length=10, layer=(1, 0))
c.write_gds(with_metadata=False)
print("Done.")
gives for me:
0.29.5
Done.
No error :(
@joamatab can you try rebuilding your env? I suspect there is some issue of an older package interfering, I also tried today and didn't get am error in a similar test
I also tried to debug the segfault, and although I can't reproduce it this way, I can see the valgrind "conditional jump depends on uninitialized value" in FT_Outline_Get_Orientation
in this code:
import freetype
from matplotlib import font_manager
font_file = font_manager.findfont("Helvetica", fallback_to_default=True)
font = freetype.Face(font_file)
font.set_char_size(32 * 64) # 32pt size
font.load_char("A", freetype.FT_LOAD_FLAGS["FT_LOAD_NO_BITMAP"])
glyph = font.glyph
outline = glyph.outline
orientation = freetype.FT_Outline_Get_Orientation(outline._FT_Outline)
This is essentially what gdsfactory does before the segfault. As there is a mix of matplotlib and freetype lib - maybe there is no binary compatibility between both?
BTW: KLayout is not involved here.
Matthias
Sebastian, i tried in two different computers with different OS, both of them running python3.11 and I get the same issue
You can see the tests for different OS and python versions here
https://github.com/gdsfactory/gdsfactory/actions/runs/10203362236/job/28229538713
I don't see that this is related to "Cannot write layer numbers larger than 65535 to GDS2 streams", but I see it is related to freetype.
I seriously think that the problem may be triggered by KLayout, but it is not the root cause.
Regarding the freetype lib, I can reproduce the following weird behavior:
This segfaults at exactly the same place than the GDSFactory tests:
import freetype
font = freetype.Face("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf")
# print(f"{font._FT_Face.contents.glyph.contents.outline}")
outline = font._FT_Face.contents.glyph.contents.outline
print(freetype.FT_Outline_Get_Orientation(outline))
This does not (not the print statement now is not commented):
import freetype
font = freetype.Face("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf")
print(f"{font._FT_Face.contents.glyph.contents.outline}")
outline = font._FT_Face.contents.glyph.contents.outline
print(freetype.FT_Outline_Get_Orientation(outline))
That is on Ubuntu 22.04 LTS with Python 3.10.12.
I think there is something wrong with the C structure bindings.
Matthias
I am a bit lost now. Is there something I should fix?
sorry, this was a strange issue,
it seems like for some OS or python versions we get some issues between klayout and freetype
i think we can close it for now