alarmserver icon indicating copy to clipboard operation
alarmserver copied to clipboard

Panic: slice bounds out of range

Open dr3amr opened this issue 2 years ago • 5 comments

Hi,

First, thanks for this, been looking for something like this to profit from embedded AI / Human detection features (instead of frigate which is cpu hog without Google Coral) outside of chinese apps / servers (I would limit internet acces to camera) and except for bellow everything works as expected.

I get bellow error few times a day and the container crashes:

panic: runtime error: slice bounds out of range [-1:]
goroutine 36 [running]:
github.com/toxuin/alarmserver/servers/hisilicon.(*Server).handleTcpConnection(0xc000184180, {0x997eb8?, 0xc00000e030})
	/tmp/app/servers/hisilicon/server.go:61 +0x805
created by github.com/toxuin/alarmserver/servers/hisilicon.(*Server).Start.func2
	/tmp/app/servers/hisilicon/server.go:126 +0x105

I have only debug:true, hisilicon and mqtt enabled. What can I do? I see there is a .handleTcpConnection method involved, which connection alarm->mqtt or camera->alarm?

dr3amr avatar Jan 10 '23 06:01 dr3amr

This is a bug, thank you for finding it! It happens when camera sends a string that is not a valid JSON and because there is not sufficient checking for such condition right now - it crashes the app, while it should just be ignored. What camera is doing that?

toxuin avatar Jan 10 '23 07:01 toxuin

I have 4x Misecu 5mp PoE cameras like bellow. Wifi is unstable but seems also PoE is unstable for these cameras. This seems like a generic camera as I saw it with different brands on Aliexpress. The video quality is good. https://a.aliexpress.com/_EI9XKcr

dr3amr avatar Jan 10 '23 08:01 dr3amr

@toxuin any ideea if this is hard to implement / fix?

dr3amr avatar Jan 11 '23 11:01 dr3amr

At the moment I have setup a rule to automatically restart the container on failure thus it is almost always available and listening for "alarms" from the AI cameras. I have an automation to turn on outside lights on human detection thus the alarm server is useful, as at the moment I do not have to use Frigate which melts the CPU as I have no Coral to help.

dr3amr avatar Jan 25 '23 09:01 dr3amr

This is a bug, thank you for finding it! It happens when camera sends a string that is not a valid JSON and because there is not sufficient checking for such condition right now - it crashes the app, while it should just be ignored. What camera is doing that?

Hi @toxuin in my case the one who is sending non valid JSON stuff is the load balancer, in order to have my alarm server always up I setup a LB in front of my alarm server and created 2 of them (alarm servers) but instantally they went down :(

aguscaba avatar Mar 02 '23 05:03 aguscaba