kytos-ng / of_core

Kytos Main OpenFlow Network Application (NApp)
MIT License
0 stars 5 forks source link

`RuntimeError: dictionary changed size during iteration` on handler `on_raw_in` #112

Closed viniarck closed 1 year ago

viniarck commented 1 year ago

This was caught on e2e tests. There's unexpected mutation going on resulting in this dict changed size during iteration, we might need a shallow copy, I'll mapping this here since it was caught on an of_core handler:

Apr 12 04:53:13 runner-rmtk68xb-project-107-concurrent-0 2023-04-12 04:53:13,965 (MainThread) kytos.core.helpers:ERROR helpers:230:  alisten_to handler: <function Main.on_raw_in at 0x7fa4ec54c700>, args: (<Main(of_core, started 140345505412864)>, KytosEvent('kytos/core.openflow.raw.in', {'source': Connection('127.0.0.1', 43780, <asyncio.TransportSocket fd=108, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 6653), raddr=('127.0.0.1', 43780)>, Switch('00:00:00:00:00:00:00:01'), <ConnectionState.ESTABLISHED: 2>), 'new_data': b'\x04\x13\x01\x18\xc7\r\xd5\xf5\x00\x01\x00\x00\x00\x00\x00\x00\x00X\x00\x00\x00\x00\x00\n.\x8d\x1d@\xc3P\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\xac\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x0e\x80\x00\x08\x06\xee\xee\xee\xee\xee\x03\x00\x00\x00\x04\x00\x18\x00\x00\x00\x00\x00\x00\x00\x10\xff\xff\xff\xfd\xff\xff\x00\x00\x00\x00\x00\x00\x00X\x00\x00\x00\x00\x00\n.n\x98\xc0\xc3P\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\xac\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x0e\x80\x00\x08\x06\xee\xee\xee\xee\xee\x02\x00\x00\x00\x04\x00\x18\x00\x00\x00\x00\x00\x00\x00\x10\xff\xff\xff\xfd\xff\xff\x00\x00\x00\x00\x00\x00\x00X\x00\x00\x00\x00\x00\x0b\x19\xdeP\x80\x03\xe8\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\xab\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x01P\x00\x01\x00\x10\x80\x00\n\x02\x88\xcc\x80\x00\x0c\x02\x1e\xd7\x00\x04\x00\x18\x00\x00\x00\x00\x00\x00\x00\x10\xff\xff\xff\xfd\xff\xff\x00\x00\x00\x00\x00\x00'}, 0)) traceback: Traceback (most recent call last):,   File "/usr/local/lib/python3.9/dist-packages/kytos/core/helpers.py", line 226, in handler_context,     result = await handler(*args),   File "//var/lib/kytos/napps/kytos/of_core/main.py", line 271, in on_raw_in,     message = connection.protocol.unpack(packet),   File "/usr/local/lib/python3.9/dist-packages/pyof/utils.py", line 60, in unpack,     message = pyof_lib.common.utils.unpack_message(packet),   File "/usr/local/lib/python3.9/dist-packages/pyof/v0x04/common/utils.py", line 183, in unpack_message,     message.unpack(msg_buff),   File "/usr/local/lib/python3.9/dist-packages/pyof/v0x04/controller2switch/multipart_reply.py", line 133, in unpack,     self._unpack_body(),   File "/usr/local/lib/python3.9/dist-packages/pyof/v0x04/controller2switch/multipart_reply.py", line 138, in _unpack_body,     obj.unpack(self.body.value),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/basic_types.py", line 807, in unpack,     super().unpack(buff, self._pyof_class, offset),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/basic_types.py", line 701, in unpack,     item.unpack(buff, begin),   File "/usr/local/lib/python3.9/dist-packages/pyof/v0x04/controller2switch/multipart_reply.py", line 313, in unpack,     super().unpack(buff[:offset+unpack_length], offset),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 732, in unpack,     size = self._unpack_attribute(name, value, buff, begin),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 652, in _unpack_attribute,     attribute.unpack(buff, begin),   File "/usr/local/lib/python3.9/dist-packages/pyof/v0x04/common/flow_match.py", line 393, in unpack,     self._unpack_attribute('oxm_match_fields', type(self).oxm_match_fields,,   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 652, in _unpack_attribute,     attribute.unpack(buff, begin),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/basic_types.py", line 807, in unpack,     super().unpack(buff, self._pyof_class, offset),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/basic_types.py", line 703, in unpack,     begin += item.get_size(),   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 678, in get_size,     return sum(cls_val.get_size(obj_val) for obj_val, cls_val in,   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 678, in <genexpr>,     return sum(cls_val.get_size(obj_val) for obj_val, cls_val in,   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 609, in _get_instance_attributes,     if name in map((lambda x: x[0]), self.get_class_attributes()):,   File "/usr/local/lib/python3.9/dist-packages/pyof/foundation/base.py", line 589, in get_class_attributes,     for name, value in cls.__dict__.items():, RuntimeError: dictionary changed size during iteration, 

I've set the target for 2023.1.

viniarck commented 1 year ago

Landed on https://github.com/kytos-ng/python-openflow/pull/85