aristocratos / bashtop

Linux/OSX/FreeBSD resource monitor
Apache License 2.0
10.76k stars 549 forks source link

[BUG] Hang on startup during CPU detection due to °C unit in temperature readout #234

Open gsuberland opened 1 year ago

gsuberland commented 1 year ago

If the sensors command is not available, the Python get_sensors() function is called instead. That function returns temperature values with "°C" appended:

https://github.com/aristocratos/bashtop/blob/60f95a1a74c8e7e589c02aa03d60141152df8337/bashtop#L4899-L4903

However, it seems that the unit is not properly removed from temperature values, causing an error on startup:

/usr/local/bin/bashtop: line 2151: (33°C-20)*100/(cpu[temp_high]-20) : syntax error: invalid arithmetic operator (error token is "°C-20)*100/(cpu[temp_high]-20) ")

This hangs bashtop in a 100% CPU loop, and a second session has to be opened to kill the process.

The error site is:

https://github.com/aristocratos/bashtop/blob/60f95a1a74c8e7e589c02aa03d60141152df8337/bashtop#L2151

The bug is probably in the Intel CPU package temperature code (and may also exist in the AMD code too), and my guess would be that the trailing unit isn't cut off, but my bash-fu isn't good enough to figure out exactly where the issue arises.

Info: