-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix infinite loop and memory exhaustion #2589
Conversation
Iterate on a copy of the existing_serials rather than extend the list being iterated
@dpwood Are you aware of @jleinenbach's PR #2580 to address #2579? |
Aware of it but not tried it. It looked like an AI attempt at a solution rather than anything focused. A lot of changes that don't seem to address the actual problem. I was having the issue very reliably and the mistake seemed clear. This one line fix has resolved it for me. Your question about conditions required for failure is a good one. I suspect number or types of Alexa devices is relevant? I'll do some more investigating. |
On startup the existing_serials is [], after a few minutes the function re-runs and in my case I have 17 entries before entering the loop, which is the number of devices I have. I then see it loop infinitely and the existing_serials array grows indefinitely. I suspect the precondition is having a device with an appDeviceList which is somehow self-referencing? The new way of adding to the list is potentially recursive. |
The new code might be appending with a serial# vs without a serial# before? I suspect my environment (10 physical "included" Echo devices) might not have any appDeviceList entities. I wonder if it might be the Alexa App "device", which I've excluded (by not including it) thereby eliminating me from experiencing the problem? |
I don't think the serial# behaviour has changed, only the way of building the list.
will have been creating a new list each time, so wouldn't suffer this issue. I've got Echo Dots, Echo Shows, Sonos, Fire TV sticks, and Alexa Mobile Voice iOS devices in the list. One of those is probably projecting an appDeviceList which has a serial that is then self-referencing. I added logging to confirm that the issue is definitely within this loop. I can easily replicate it (happens every time). It is also resolved with this change. |
Thanks! |
I just want to say sorry that I was unable to fix it fast. I tested the version, but not long enough as it seems. I am still trying to improve the code, but I will test it much longer now! |
somehow the infinite loop is still there for me after upgrading to the new version and newest HA-Version. |
Iterate on a copy of the existing_serials rather than extend the list being iterated causing infinite iteration
Fixes #2579