Prevent infinite loop when only BOT_PREFIX passed#1557
Prevent infinite loop when only BOT_PREFIX passed#1557sijis merged 2 commits intoerrbotio:masterfrom
Conversation
|
As I understand the code, the proposed change will stop processing the first element of the command. I'm interested in reproducing the infinite loop issue. Can you provide the following information so I can setup errbot as close to your setup please:
|
|
Sure thing! I've been able to reproduce this on version To reproduce, I fire up the bot with |
|
Perhaps a better way to resolve the issue here would be by checking if the |
|
Sorry for the delay, I was able to reproduce the infinite loop as you described. This a really great catch, thank you for reporting this. Your initial PR is a good solution. As a small bonus, if the test is moved from the bottom of the loop to the top and test for any value lower than 1, it will avoid the infinite loop as well as not spend time and resource to acquire the thread lock when the test_split list is empty. |
|
Moving the test to the top of the loop breaks code elsewhere in the function. Your initial fix is the right one. 👍 |
15e7e94 to
7c97a75
Compare
* Prevent infinite loop when only BOT_PREFIX passed * docs: add info to CHANGES Co-authored-by: Sijis Aviles <sijis.aviles+github@gmail.com>
I have hit an error in which a message that contains only my bot prefix causes the bot to become unresponsive to any further messages. After a bit of debugging, I believe the problem is that
texthere becomes an empty string, which makes the value ofistart as 0, then decrement (because the empty string is not incommands), leading to an infinite loop whereidecreases forever.I have confirmed that changing the comparison operation to
<=fixes this case, without breaking other commands as far as I can tell.