-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Infinite loop when executing DataFlow queries #7481
Comments
How do you define "forever"? 10 minutes? 1 hour? 10 hours? 1 day? I've been running codeql queries for over 24 hours on huge databases (Mozilla Firefox). |
The iteration number keeps increasing forever. I executed one (relatively simple) query and it did not finish for more than 3 days. Does it make sense? |
Greetings, thanks for reaching out to us with this question. It certainly is possible for queries to take a very long time on large databases - perhaps even days if the database is sufficiently large. Seeing predicates take hundreds of iterations is also not entirely uncommon, especially in some of the more complex parts of the data flow library. Some common ways of speeding up our evaluation times include increasing the It should not be possible for any CodeQL query to take forever - the CodeQL engine should refuse to evaluate things that won't provably terminate. However, it's possible (although unlikely) that there may be a bug and your query will genuinely never terminate. If the above suggestions don't help your query get a result, I'd be happy to look into this further for you if you could provide us with the database you are using and what query you are trying to evaluate. |
This issue is stale because it has been open 14 days with no activity. Comment or remove the |
This issue was closed because it has been inactive for 7 days. |
Hi, I have noticed that even if I execute the following simple query:
I get the same behavior. I am pretty sure it has to be some bug in the DataFlow standard library. |
The log snippet at the top does not indicate looping (the varying row counts is an indication that progress is being made). However, certain types of bugs in the QL libraries related to |
Unfortunately, this is a closed source project, so I cannot share the source code / database. I tinkered a bit with the codeql standard library, and I have noticed some interesting behaviors which may help to identify the root cause: In this qll file: https://github.com/github/codeql/blob/main/java/ql/lib/semmle/code/java/dataflow/internal/DataFlowNodes.qll
Suddenly the above query ( Another interesting fact I have noticed is: Without commenting out those parts (when the query does get stuck), it always has 23+ execution stages, and it always gets stuck 1 stage before the last one (22/23, 23/24, ...). When there are less stages (usually 13 after I comment out those lines), it always works. Is there something else I can test to help you identify the issue? Thanks for your help! |
Those facts are unfortunately somewhat arbitrary and don't reveal much - it's only saying that when you don't evaluate the part that's broken then it doesn't appear broken. The log snippet you originally posted is more useful, except the snippet above was only after 115s of eval. We'd need to look at the end of the log from the point where it really starts to "loop". The log can be augmented with additional debug info through the option "Code QL > Running Queries: Debug" in VSCode. |
Hi @aschackmull I have found the root cause of the issue. You can reproduce the issue by building a database containing a single class with the following code:
A class in my project contains this code pattern. I am not sure if it's considered a bug or not (because the code does not actually compile), but I do think it should be fixed. |
Thanks for the minimal test case -- candidate fix: #8155 |
@smowton Wouldn't ignoring those files cause queries to miss out some results sometimes? |
The files have compile errors, so I don't think it would be important |
This issue is stale because it has been open 14 days with no activity. Comment or remove the |
This issue is stale because it has been open 14 days with no activity. Comment or remove the |
I have built a CodeQL database for my Java project. I am able to execute simple queries on it, but when I attempt to execute a DataFlow query, The execution gets stuck in an infinite loop (probably in the
ModulusAnalysis::phiModulusRankStep
method) and never finishes. The log for such a query looks like this:It continues like this forever.
The text was updated successfully, but these errors were encountered: