aristocratos / bpytop

Linux/OSX/FreeBSD resource monitor
Apache License 2.0
10.1k stars 396 forks source link

[BUG] Crash when switching through CPU sensor options #261

Open lbhm opened 3 years ago

lbhm commented 3 years ago

Describe the bug After reading #256, I got curious to see what CPU sensor options are available on my Ryzen 3600. So I went to the options menu and switched through the CPU sensor options. However, when I am switching from the last option to the first, bpytop crashes with exit code 1:

Bpytop exited with errorcode (1). See /home/lbhm/.config/bpytop/error.log for more information!

The error log shows:

13/02/21 (09:30:01) | ERROR: Data collection thread failed with exception: 'NotImplementedType' object is not callable
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2909, in _runner
    collector._draw()
  File "/usr/bin/bpytop", line 3201, in _draw
    CpuBox._draw_fg()
  File "/usr/bin/bpytop", line 1945, in _draw_fg
    out += f'{THEME.inactive_fg}{"⡀" * (5 * cls.column_size + ct_width)}{Mv.l(5 * cls.column_size + ct_width)}{THEME.gradient["cpu"][cpu.cpu_usage[n][-1]]}{Graphs.cores[n-1](None if cls.resized else cpu.cpu_usage[n][-1])}'
TypeError: 'NotImplementedType' object is not callable
13/02/21 (09:30:01) | WARNING: Exiting with errorcode (1). Runtime 0:01:35 

To Reproduce

  1. Start bpytop
  2. Press escape to open the options menu
  3. Switch to the CPU sub-menu
  4. Switch through the CPU sensor options from start to end and one step further back to the start
  5. Program crashes when switching from last to first

Expected behavior

The CPU sensor selection should switch back to the first option instead of crashing.

Screenshots

[If applicable, add screenshots to help explain your problem.]

Info (please complete the following information):

aristocratos commented 3 years ago

@lbhm I can't reproduce this and are not really sure how it would crash with this particular error, since the line causing a error is not related to CPU temperature.

Can you run python3 -c 'import pprint, psutil; pp = pprint.PrettyPrinter(); pp.pprint(psutil.sensors_temperatures())' and post the output?

lbhm commented 3 years ago

Sure:

[lbhm@manjaro ~]$ python3 -c 'import pprint, psutil; pp = pprint.PrettyPrinter(); pp.pprint(psutil.sensors_temperatures())'
{'k10temp': [shwtemp(label='Tctl', current=56.25, high=None, critical=None),
             shwtemp(label='Tdie', current=56.25, high=None, critical=None),
             shwtemp(label='Tccd1', current=38.5, high=None, critical=None)],
 'nvme': [shwtemp(label='Composite', current=26.85, high=84.85, critical=84.85),
          shwtemp(label='Sensor 1', current=26.85, high=65261.85, critical=65261.85),
          shwtemp(label='Sensor 2', current=41.85, high=65261.85, critical=65261.85)]}

These are also the options that I am seeing in the CPU sensor selection.

I am also not able to reproduce this crash every time I try it. But starting bpytop a couple of times and switching through the sensor options, I was able to reproduce the crash six times by now.

Maybe this is completely unrelated by I think that the crash is more likely to happen with my default terminal size (104x28) than if I put the terminal into full-screen mode. Is this maybe something rendering related that only happens with the CPU sensor selection by chance?

Edit: I tried out a few more terminal sizes and was able to reproduce the crash on small terminal sizes like 104x28 or 80x24 by just switching through the selection for long enough but couldn't reproduce it with a full-screen terminal so far.

aristocratos commented 3 years ago

@lbhm This may be caused by my implementation of multithreading in bpytop. When you switch through the different sensor options the CPU box is triggered to be redrawn, you might be able to get the CPU box to redraw before the CPU core graphs have been recreated (if you trigger this fast enough or have a slow cpu) which would cause this error.

Will take a look at preventing this from being able to happen when I've got some time.