Repository navigation
Don't cap the similarity score when neither binary has flow graph edges - #93
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the CallGraph version of GetSimilarityScore in differ.cc to handle cases where both sides have zero flow graph edges, preventing the similarity score from being capped at 0.65. It also adds a unit test in differ_test.cc to verify this behavior. The reviewer points out that the same issue exists in the FlowGraph overload of GetSimilarityScore and suggests applying a similar fix there to avoid penalizing single-block functions.
rootkiller6788
marked this pull request as ready for review
October 16, 2026 03:58
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.
Fixes #90.
When neither binary has any flow graph edges (every function is a single basic block with no calls), the edge term in the call graph similarity score is necessarily 0, which caps the whole score at 0.65. I made that term count as a match when both sides have zero edges, which is what was suggested in the issue.
Where only one side has edges I left the term at zero. The two binaries really do differ in control flow there, so they shouldn't get the credit for it.
To check it I pulled the function body out of differ.cc and compiled it standalone against the real statistics.h (stubbing out CallGraph and GetConfidence, which the formula only reads through). A self-diff with no edges goes 0.650000 -> 1.000000, the all-edges-match case stays 1.000000, and the one-sided case stays 0.650000.
One thing worth flagging: differ_test.cc doesn't look like it's built by the OSS CMakeLists -- the test targets there cover call_graph, change_classifier, config, database_writer, match, prime_signature, sqlite and writer, and differ_benchmark.cc (which CMakeLists does reference) isn't in the tree either. So the test I added won't actually run on GitHub CI. I left CMakeLists alone since I can't build it here to verify a change. Happy to wire it up in a separate PR if you want it running.