-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Go: fix small issues highlighted by data flow consistency checks #20929
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
base: main
Are you sure you want to change the base?
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.
Pull request overview
This PR addresses small issues identified by data flow consistency checks in the Go language implementation. The main focus is on fixing the reverseRead consistency check violations, which occur when a read step exists from node a to a.b, node a.b has a post-update node, but node a is missing its post-update node.
Key Changes
- Extended post-update node generation for method call receivers to include all implicit field reads in promoted field access chains
- Refactored
skipImplicitFieldReadsinFlowSummaryImpl.qllto use a new utility predicatelookThroughImplicitFieldRead - Added exclusion predicates to the Go consistency checks for known acceptable edge cases
- Fixed an SSA implementation issue where adjacent variable references could incorrectly include self-loops
Reviewed changes
Copilot reviewed 63 out of 64 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
shared/dataflow/codeql/dataflow/internal/DataFlowImplConsistency.qll |
Added localFlowIsLocalExclude exclusion predicate and documentation for reverseRead check |
go/ql/lib/semmle/go/dataflow/internal/DataFlowImplConsistency.qll |
Implemented Go-specific exclusion predicates for consistency checks |
go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll |
Extended post-update node creation to handle promoted field access chains using transitive closure |
go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll |
Refactored to use new IR::lookThroughImplicitFieldRead utility predicate |
go/ql/lib/semmle/go/dataflow/SsaImpl.qll |
Added condition to prevent self-loops in adjacent variable reference detection |
go/ql/lib/semmle/go/controlflow/IR.qll |
Added lookThroughImplicitFieldRead utility predicate for consistent field read navigation |
go/ql/consistency-queries/UnexpectedFrontendErrors.ql |
Moved query to consistency-queries directory |
go/ql/lib/change-notes/2025-11-26-unexpected-frontend-errors-query-moved.md |
Change note documenting the query move |
go/Makefile |
Updated consistency queries path references |
Multiple .expected files |
Updated test expectations with reverseRead consistency check results |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
go/ql/lib/change-notes/2025-11-26-unexpected-frontend-errors-query-moved.md
Outdated
Show resolved
Hide resolved
62e254e to
ac90f7a
Compare
ac90f7a to
a20c8cf
Compare
|
QA showed a few alert changes which helped me find a bug. I had previously tracked the identity steps down to |
|
I ran DCA on the 16 repos which had alert differences in the QA run. This confirmed that the fix has worked and there are now no alert differences. There are still no noticeable performance changes. So I think this is ready for review. |
| // then mri.getReceiver() will give us the implicit field read a.b.c | ||
| // and we want to have post-update nodes for a, the implicit field | ||
| // read a.b and the implicit field read a.b.c. | ||
| insn = IR::lookThroughImplicitFieldRead*(mri.getReceiver()) |
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.
Should this instead be a general rule saying: If we have a post-update node for a.b then we also need one for a?
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.
Looking more closely, I see that actually we already deal with reads of promoted fields (in insn = getAWrittenInsn()), and this change is actually about receivers of calls to promoted methods. (I've just updated the description.) To your point, doing that would make the predicate recursive and less transparent. Since I've determined exactly what was missing from the previous definition, I feel like the most straightforward thing is to just add it to the predicate.
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.
Ok, as long as the logic covers satisfies the implication I mention above.
This PR contains wo small tweaks to the go library to remove some results from the data flow consistency queries.
SelectorExpra.fwhich is reading a promoted method, and it's equivalent toa.B.C.fif we add all the implicit reads of embedded fields. Currently we only create a post-update node fora. This PR also adds them for the implicit field read nodes corresponding toa.Banda.B.C, which should allow the "reverse read" feature of the data flow library to work.QA has been run and shows no performance problems or alert changes (after I fixed a mistake in how I got rid of the identical steps).
Commit-by-commit review is recommended.