C++: Fix the two null termination queries and re-enable them. #6915
Conversation
…in NullTermination.qll.
This reverts commit f38dade.
|
It looks like a join-ordering issue where I think you can get a simpler (and behaviour-preserving) fix by replacing: mayAddNullTerminatorHelper(e, va, e0) and
bb.getNode(pos) = e and
bb0.getNode(pos0) = e0with mayAddNullTerminatorHelper(pragma[only_bind_into](e), va, pragma[only_bind_into](e0)) and
pragma[only_bind_into](bb).getNode(pos) = e and
pragma[only_bind_into](bb0).getNode(pos0) = e0that should force the compiler to only compute |
|
I've pushed a commit updating to your suggestion, then a commit applying similar changes to |
|
The naive version using |
Indeed, I think it would be super nice to have a transitive version of
For now, I think it's best to make |
|
I've added some tests, fixed a bug revealed by the tests, renamed the predicate (though we can and should use a shorter name if we make it a member predicate of
|
LGTM! The PR check failure is not related to this PR.
Would it help if I retry the check, or merge latest main? |
Yes. This has been fixed on the latest main. So you should be fine if you retry. |
|
I don't seem to be able to get DCA working right now. I'll try again / try something else to confirm performance tomorrow. |
|
Do tell me if I can help with anything! |
|
DCA results are in:
So the performance improvements are good, but I think this isn't quite ready to merge yet... |
This is my proposed fix (update: major contributions from @MathiasVP) for performance of the two null termination queries that regressed the CPP-Differences suite last week (caused by #6794 and temporarily fixed by #6893).
It is not behaviour preserving, as I didn't have much luck making an improvement that was.I'm very much open to suggestions of other approaches and discussions about tradeoffs.This PR also re-enables the two queries as they should now perform acceptably.
The issue is in the
NullTermination.qlllibrary, that is only used by these two queries. It does not appear to be related to the recent QL changes themselves, rather just the fact that these queries were enabled. The issue does not affect all projects, but for example inphpthe time to computemayAddNullTerminatorexploded (specifically the "Assignment to another stack variable" part).Performance:
294s295s forcpp/improper-null-terminationand 882s ->529s538s forcpp/user-controlled-null-termination-taintedonphp(the remaining time I believe is largely cache warmup of SSA, def-use etc).the DCA results show a 28% speedup onTODO: re-run with the new strategy.phpcomparable to the original slowdown that is 32% of the slow run.1130s939s forcpp/improper-null-terminationonwireshark; less of a speedup, the issue inmayAddNullTerminatoris resolved but there may be a similar problem invariableMustBeNullTerminatedthat remains.Results:
the change makes the "Assignment to another stack variable" case coarser, thusmayAddNullTerminatoris wider so we will in principle see fewer query results.in local runs, on tests, and on DCA I saw no query differences.TODO: it's probably worth running an LGTM diff query, there will likely be something to see.@MathiasVP - I've not made this a draft, but I feel we should discuss it and possibly iterate before merging.
The text was updated successfully, but these errors were encountered: