-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
coretasks: fix bad WHO tracking endless loop #2091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. This should be noted as a successful week of bug hunt!
d481569
to
a56c0ee
Compare
Sorry, @Exirel, I have to reject your approval. See commit message for Included the update with this PR since it is closely related to the bugfix, and a separate PR would immediately move/remove some of the fix changes. IMO, should be updated eventually, so why not now, eh? I'm happy to discuss alternatives to this combo. |
PR has changed significantly (4fc75c1) since review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm nitpicking. It's my job, no? 😁
Nothing here is part of Sopel's documented API, thankfully. This is probably safe to release as part of 7.1.1, though I wish the "type" of WHO query could be non-numeric. 000
is something other people might already use in their plugins (though I did search GitHub for "sopel who 000" in all indexed Python code and found a total of 10 irrelevant hits—it's probably perfectly fine).
Oh well. Up to now it was possible to get Heisenbugs if the random integer happened to collide with some custom code's WHO requests. Now it'll be consistent, and therefore easier to find/fix.
Wellll actually, nowhere does it "officially" say it has to be numeric (where officially refers to IRCd docs, and not random forums on the interwebz). The pages cited in the comments (and commit message) use numbers in the example and one uses the term "digits" (which I Looking at the source for IRCd's that implement … what to do?? |
Yeah, you read the same Faerion page I did, which is where the "digits" thing came from. What annoys me about WHOX is that there seems to be no real spec to follow…which means we're stuck doing what you did, and what I presume the previous maintainers did: digging through IRCd source code. Not great. In the absence of such a spec, though, I'd be wary of doing anything that might run afoul of older IRCds' logic. Your checks validate that being numeric isn't required now, but perhaps it was in the past. A counterexample I found is from DareNET's current documentation (snapshot) on WHOX: it specifies "value between 0 and 999". Seriously, though. We can commiserate over the lack of a formal standard for WHOX all we want, but the endgame is always going to be "leave it as 000; it's fine". 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as dgw: let's remove that end_who
plugin callable.
who_reqs, which is used to track WHO requests to the server, had flipped keys/values and was never getting cleared upon RPL_ENDOFWHO. Eventually, this would lead to an endless loop while the bot tried to get an unused "querytype" (randint) in order to track WHO replies. This unneccessary loop/check to ensure unique values for the query type was removed. A RPL_WHOREPLY includes the channel name in the response, so confirming that the querytype for a channel matched is sufficient. querytype should be unique _per purpose_. So, now a constant querytype is used for `coretasks` WHO(X) requests. Notes: According to [the closest thing to] official specs: ircv3/ircv3-specifications#81 (comment) querytypes should be useful to: > simplify scripting, in example one could pass a certain value in the query > and have that value "signal" back what is to be done with those replies. Also see: https://github.com/quakenet/snircd/blob/17c92003d376c70db674821e92f2880ba1587132/doc/readme.who#L154 https://github.com/quakenet/snircd/blob/17c92003d376c70db674821e92f2880ba1587132/doc/readme.who#L105
4fc75c1
to
f11dca5
Compare
@dgw, based on your reasoning, I have actually decided to change it to In other news, I made the rest of the requested changes and squashed the original loop fix + set querytype constant commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉🥳🚀
So, if an old IRCd casts a querytype with value < 100 to a numeric, it may end up causing false negatives when, for example,
"42" != "042"
.
That is a good point! It's no reason to amend the PR, but just so you know how silly I am: I probably would have picked something like "Sopel" encoded to T9 with the vowels removed ("775"), or a common "lucky" number like 777 or 888. 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge that and publish a 7.1.1 asap.
who_reqs, which is used to track WHO requests to the server, had flipped keys/values and was never getting cleared upon RPL_ENDOFWHO. Eventually, this would lead to an endless loop while the bot tried to get an unused "querytype" (randint) in order to track WHO replies. This unneccessary loop/check to ensure unique values for the query type was removed. A RPL_WHOREPLY includes the channel name in the response, so confirming that the querytype for a channel matched is sufficient. querytype should be unique _per purpose_. So, now a constant querytype is used for `coretasks` WHO(X) requests. Notes: According to [the closest thing to] official specs: ircv3/ircv3-specifications#81 (comment) querytypes should be useful to: > simplify scripting, in example one could pass a certain value in the query > and have that value "signal" back what is to be done with those replies. Also see: https://github.com/quakenet/snircd/blob/17c92003d376c70db674821e92f2880ba1587132/doc/readme.who#L154 https://github.com/quakenet/snircd/blob/17c92003d376c70db674821e92f2880ba1587132/doc/readme.who#L105 ---- Backport to 7.1.1 release of pull request #2091, commit f11dca5
Description
who_reqs
, which is used to trackWHO
requests to the server, had flippedkeys/values and was never getting cleared upon
RPL_ENDOFWHO
.Eventually, this would lead to an endless loop while the bot tried to
get an unused "querytype" (
randint
) in order to trackWHO
replies.Now, key/values are in a more useful order (channel --map--> querytype).
Also, the unneccessary loop used to ensure unique values for the query type was
removed. A
RPL_WHOREPLY
includes the channel name in the response, soconfirming that the querytype for a channel matched is sufficient. The same
querytype could even be used for every channel without issue.
Checklist
make qa
(runsmake quality
andmake test
)