joshuar / go-hass-agent

A Home Assistant, native app for desktop/laptop devices.
MIT License
128 stars 9 forks source link

[BUG] panic: runtime error: invalid memory address or nil pointer dereference (on LXC Desktop) #170

Closed GrumpyMeow closed 4 weeks ago

GrumpyMeow commented 3 months ago

Go Hass Agent Version Go Hass Agent: v9.2.0

Describe the bug Upon running go-hass-agent i get this output:

system@desktop2:~$ go-hass-agent run
11:21AM WRN Could not retrieve battery list. Cannot find any existing batteries. error="SystemBus: unable to get data org.freedesktop.UPower.EnumerateDevices from org.freedesktop.UPower: The name org.freedesktop.UPower was not provided by any .service files"
11:21AM WRN Sensor not found in registry. id=agent_version
11:21AM WRN Sensor not found in registry. id=agent_version
11:21AM WRN Sensor not found in registry. id=mountpoint_root
11:21AM WRN Sensor not found in registry. id=mountpoint_root
11:21AM WRN Sensor not found in registry. id=nvme0n1_disk_reads
11:21AM WRN Sensor not found in registry. id=nvme0n1_disk_reads
11:21AM WRN Sensor not found in registry. id=nvme0n1_disk_read_rate
11:21AM WRN Sensor not found in registry. id=nvme0n1_disk_read_rate
11:21AM WRN Sensor not found in registry. id=kernel_version
11:21AM WRN Sensor not found in registry. id=kernel_version
11:21AM WRN Sensor not found in registry. id=cpu_load_average_(15_min)
11:21AM WRN Sensor not found in registry. id=cpu_load_average_(15_min)
11:21AM WRN Sensor not found in registry. id=bytes_sent_throughput
11:21AM WRN Sensor not found in registry. id=bytes_sent_throughput
11:21AM WRN Sensor not found in registry. id=power_state
11:21AM WRN Sensor not found in registry. id=power_state
11:21AM WRN Sensor not found in registry. id=idle
11:21AM WRN Sensor not found in registry. id=idle
11:21AM WRN Sensor not found in registry. id=last_reboot
11:21AM WRN Sensor not found in registry. id=last_reboot
11:21AM WRN Sensor not found in registry. id=current_users
11:21AM WRN Sensor not found in registry. id=current_users
11:21AM WRN Sensor not found in registry. id=uptime
11:21AM WRN Sensor not found in registry. id=uptime
11:21AM WRN Sensor not found in registry. id=lo_connection_state
11:21AM WRN Sensor not found in registry. id=lo_connection_state
11:21AM WRN Sensor not found in registry. id=bytes_sent
11:21AM WRN Sensor not found in registry. id=bytes_sent
11:21AM WRN Sensor not found in registry. id=cpu_load_average_(1_min)
11:21AM WRN Sensor not found in registry. id=cpu_load_average_(1_min)
11:21AM WRN Sensor not found in registry. id=distribution_name
11:21AM WRN Sensor not found in registry. id=distribution_name
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xd487ae]

goroutine 39 [running]:
github.com/joshuar/go-hass-agent/pkg/linux/hwmon.GetAllSensors()
        /home/runner/work/go-hass-agent/go-hass-agent/pkg/linux/hwmon/hwmon.go:394 +0xae
github.com/joshuar/go-hass-agent/internal/linux/system.HWSensorUpdater.func1(0xc000408400?)
        /home/runner/work/go-hass-agent/go-hass-agent/internal/linux/system/hwmon.go:99 +0x25
github.com/joshuar/go-hass-agent/internal/device/helpers.PollSensors.func1()
        /home/runner/work/go-hass-agent/go-hass-agent/internal/device/helpers/polling.go:27 +0x6f
created by github.com/joshuar/go-hass-agent/internal/device/helpers.PollSensors in goroutine 245
        /home/runner/work/go-hass-agent/go-hass-agent/internal/device/helpers/polling.go:25 +0x125

Expected behaviour I understand the error about not able to find Upower. This as i'm using a virtualized environment. I uninstalled all power-saving stuff (such as upower). Otherwise the environment would controll the whole machine/host.

Desktop (please complete the following information):

joshuar commented 2 months ago

Hey there,

That is an odd error. I'm having a bit of trouble trying to reproduce and understand how the code referenced in the stack trace could result in a nil pointer panic. Would you be able to run the agent with debug logging enabled, that might reveal some more details that could help with troubleshooting. You can run the agent with debug with the following command:

go-hass-agent --log-level debug run

Thanks for trying out the agent!

joshuar commented 2 months ago

Hey there, just wanted to follow-up and see if you can provide debug level logging with the command I posted above? Also, there is a new version that is worth trying with as a lot of code was refactored: v9.4.0.

joshuar commented 2 months ago

Hey there, I haven't been able to reproduce this myself. I would need some more information, such as a debug logs I've requested, in order to continue troubleshooting this issue. Would you be able to try the latest release and if the issue is still present, provide debug logs?

joshuar commented 4 weeks ago

I'm going to close this issue off as I haven't been able to reproduce and do not have enough details to troubleshoot further. There have also been a lot of changes to the code since this issue was reported, so it would be worth first trying with the latest release to see if the problem persists.