Improve localTaint predicate performance in STLContainer. - #1198
Open
MichaelRFairhurst wants to merge 2 commits into
Open
MichaelRFairhurst wants to merge 2 commits into
MichaelRFairhurst wants to merge 2 commits into
Conversation
Previous implementation was using nomagic to prevent bad joins from being introduced in localTaint. However, this forces the evaluator to construct the entire graph of local taint paths, which is about 25 million tuples on pandas. This blocks updating to new dataflow where the performance issues get worse. The evaluator creates `additionalTaintStep+`, a relation with 6.7 billion rows. This is done via a higher-order-predicate and is surprisingly fast (8sec). However, the next step takes the `+`-style transitive closure and tries to make the `*` version, by unioning the `+` version with a scan of all dataflow nodes n into tuples (n, n)`. I don't know why this union OOMs, to be honest, but the crash stack trace includes an "unsorted relation writer," which maybe indicates that the OOM comes from trying to sort the 6.7 billion values. In any case, I'm satisfied that we shouldn't be constructing a 6.7 billion relation here. Fixed by identifying the root candidate set of expressions that come from container function calls that we're interested in, which is 799 nodes on pandas, and then the transitive relation `containerTaint` is just 1765 rows on old dataflow. On new dataflow this is 701 sources and 5779 nodes in the transitive closure.
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The semantic rewrite appears sound, but its compilation and dataset-scale performance could not be independently validated.
Review effort: Balanced
Findings: None
What changed in this PR
Scopes local taint evaluation to relevant STL container call results, avoiding construction of the full taint graph while preserving query semantics.
Changes:
- Adds source-filtered container taint predicates.
- Adds the required performance change note.
- Unverified: shared-query execution and OpenPilot performance results.
| File | Description |
|---|---|
cpp/common/src/codingstandards/cpp/standardlibrary/STLContainers.qll |
Restricts local taint traversal to relevant container calls. |
change_notes/2026-09-16-improve-iterator-access-check-performance.md |
Documents the performance optimization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous implementation was using nomagic to prevent bad joins from being introduced in localTaint. However, this forces the evaluator to construct the entire graph of local taint paths, which is about 25 million tuples on pandas.
This blocks updating to new dataflow where the performance issues get worse. The evaluator creates
additionalTaintStep+, a relation with 6.7 billion rows. This is done via a higher-order-predicate and is surprisingly fast (8sec). However, the next step takes the+-style transitive closure and tries to make the*version, by unioning the+version with a scan of all dataflow nodes n into tuples (n, n)`. I don't know why this union OOMs, to be honest, but the crash stack trace includes an "unsorted relation writer," which maybe indicates that the OOM comes from trying to sort the 6.7 billion values. In any case, I'm satisfied that we shouldn't be constructing a 6.7 billion relation here.Fixed by identifying the root candidate set of expressions that come from container function calls that we're interested in, which is 799 nodes on pandas, and then the transitive relation
containerTaintis just 1765 rows on old dataflow. On new dataflow this is 701 sources and 5779 nodes in the transitive closure.Description
please enter the description of your change here
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
CTR55-CPPRelease change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.