markqvist / NomadNet

Communicate Freely
GNU General Public License v3.0
1.17k stars 44 forks source link

Crash on announce receive handler #30

Closed faragher closed 1 year ago

faragher commented 1 year ago

One of my NomadNet programs crashes every few days to few weeks. I just caught the log:

[2023-08-09 14:17:37] [Extra] Valid announce for <a6ff59611bb0f4674db719e94885e7ae> 2 hops away, received via <445853aca89b5d92d02dd2f727896a35> on LocalInterface[37428]
[2023-08-09 14:17:37] [Debug] Destination <a6ff59611bb0f4674db719e94885e7ae> is now 2 hops away via <445853aca89b5d92d02dd2f727896a35> on LocalInterface[37428]
[2023-08-09 14:17:37] [Error] An unhandled exception occurred, the details of which will be dumped below
[2023-08-09 14:17:37] [Error] Error while processing external announce callback.
[2023-08-09 14:17:37] [Error] Type  : <class 'AttributeError'>
[2023-08-09 14:17:37] [Error] The contained exception was:
[2023-08-09 14:17:37] [Error] Value : 'ListEntry' object has no attribute '_cache_translation'
[2023-08-09 14:17:38] [Error] Trace :
  File "/home/faragher/.local/bin/nomadnet", line 8, in <module>
    sys.exit(main())
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/nomadnet.py", line 51, in main
    program_setup(configarg, rnsconfigarg, daemon, console)
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/nomadnet.py", line 11, in program_setup
    app = nomadnet.NomadNetworkApp(
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/NomadNetworkApp.py", line 362, in __init__
    nomadnet.ui.spawn(self.uimode)
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/ui/__init__.py", line 29, in spawn
    return TextUI()
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/ui/TextUI.py", line 207, in __init__
    self.loop.run()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 790, in run
    self._loop()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 818, in _loop
    self._entering_idle()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 779, in _entering_idle
    callback()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 574, in entering_idle
    self.draw_screen()
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/main_loop.py", line 588, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/container.py", line 1089, in render
    body = self.body.render((maxcol, maxrow-ftrim-htrim),
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/container.py", line 2130, in render
    canv = w.render(sub_size,
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 1761, in render
    canv = get_delegate(self).render(size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/container.py", line 1565, in render
    canv = w.render((maxcol, rows), focus=focus and item_focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/container.py", line 2130, in render
    canv = w.render(sub_size,
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/decoration.py", line 819, in render
    canv = self._original_widget.render((maxcol,maxrow-top-bottom),focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/nomadnet/vendor/additional_urwid_widgets/widgets/indicative_listbox.py", line 109, in render
    middle, top, bottom = self._listbox.calculate_visible(modified_size, focus=focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/listbox.py", line 389, in calculate_visible
    n_rows = next.rows( (maxcol,) )
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 205, in cached_rows
    return fn(self, size, focus)
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 1019, in rows
    return len(self.get_line_translation(maxcol))
  File "/home/faragher/.local/lib/python3.10/site-packages/urwid/widget.py", line 1035, in get_line_translation
    return self._cache_translation

[2023-08-09 14:17:38] [Verbose] Saving directory...
[2023-08-09 14:17:38] [Verbose] Nomad Network Client exiting now
[2023-08-09 14:17:38] [Debug] Saved 26 peers to storage

It appears it's attempting to call _cache_translation on a list, which may be an error handling problem in NomadNet or an implementation problem in urwid.

Instance is running over SSH and has not had its size changed since NN startup.

markqvist commented 1 year ago

Thanks for capturing and providing the log. These cache errors crop up from urwid every now and then, and are a bit of a pain to troubleshoot. For now, I'll wrap the announce handler to catch the exception when it occurs, since it should only affect one UI update cycle.