Tribler / py-ipv8

Python implementation of Tribler's IPv8 p2p-networking layer
GNU Lesser General Public License v3.0
231 stars 47 forks source link

AttributeError: 'Peer' object has no attribute 'address' #729

Closed devos50 closed 4 years ago

devos50 commented 4 years ago

As reported by a Tribler RC4 user:

Traceback (most recent call last):
File "src\tribler-gui\tribler_gui\event_request_manager.py", line 114, in on_read_data
RuntimeError: 'Peer' object has no attribute 'address'
--LONG TEXT--
Traceback (most recent call last):
File "lib\asyncio\events.py", line 88, in _run
File "lib\asyncio\selector_events.py", line 965, in _read_ready
File "ipv8\messaging\interfaces\udp\endpoint.py", line 28, in datagram_received
File "ipv8\messaging\interfaces\endpoint.py", line 85, in notify_listeners
File "ipv8\messaging\interfaces\endpoint.py", line 73, in _deliver_later
File "ipv8\community.py", line 322, in on_packet
File "ipv8\peerdiscovery\network.py", line 188, in get_verified_by_address
AttributeError: 'Peer' object has no attribute 'address'
--CONTEXT--
{'message': 'Exception in callback _SelectorDatagramTransport._read_ready()', 'exception': AttributeError("'Peer' object has no attribute 'address'"), 'handle': <Handle _SelectorDatagramTransport._read_ready()>}
qstokkink commented 4 years ago

Normal Peer objects definitely always have an address field:

https://github.com/Tribler/py-ipv8/blob/239912f03b107d8d491b7728312ce3890d23b38d/ipv8/peer.py#L27

I guess something is injecting Peer subclasses without one (which can happen if you forget to call super(...).__init__)?

qstokkink commented 4 years ago

This is the code it fails on (line 188), also the only way to insert into reverse_ip_lookup:

https://github.com/Tribler/py-ipv8/blob/3cee7066a7e91bf9cab5478b81ec90058cedbfb1/ipv8/peerdiscovery/network.py#L176-L188

This dict cannot even contain a Peer that did not have an address to begin with (see line 182 -- which is the only code actually adding to this dictionary).

qstokkink commented 4 years ago

Second thought: possibly something is calling del on the Peer object externally.