-
Notifications
You must be signed in to change notification settings - Fork 3
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
Indexing by threadid()
should be avoided
#2
Conversation
Actually, on second thoughts, shouldn't these go in |
@aviks I moved them. |
A common use case for |
So my understanding from that blog post was that with task migration, that code will not do what you want. Am I misunderstanding some nuance, or are you saying that that blog post overstates things? More generally, I don't think any static analysis rule is fully universal. You need to decide on what works for your use case, and then choose a set of rules to enforce your polices automatically. So in my mind, the benchmark for a rule is "would at least a few people feasibly want to enforce this". None of these are meant to be universally applicable to everybody or every codebase. |
The code Kristoffer linked should always be fine because of the
Is there some way to mark this as a "low confidence check" or something like that? Or can we bump down the severity a notch? |
Something like this? https://semgrep.dev/docs/contributing/contributing-to-semgrep-rules-repository/#confidence |
OK, we could make this rule match only when |
It depends if the code hits a yield point in |
Yes, but you can't statically determine this.
I think so. Imho this rule should be a
but seems more robust. Excessive amounts of false positives will lead to users disabling rules very quickly. |
@pfitzseb Something like this? https://semgrep.dev/playground/s/B955 |
yeah, or even https://semgrep.dev/playground/s/DWjj |
I changed the rule according to @pfitzseb's suggestions (changed |
Indexing by
Threads.threadid()
can lead to race conditions, as explained in the blogpost mentioned in this PR. I added a rule to match this case.