Skip to content
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

Remove the use of XOR hashing in extraHash computation #1399

Open
Friendseeker opened this issue Sep 19, 2024 · 0 comments
Open

Remove the use of XOR hashing in extraHash computation #1399

Friendseeker opened this issue Sep 19, 2024 · 0 comments
Assignees

Comments

@Friendseeker
Copy link
Member

Friendseeker commented Sep 19, 2024

val analysis = handler.previousAnalysis
val externalParents = analysis.relations.inheritance.external.forward(className)
val internalParents = analysis.relations.inheritance.internal.forward(className)
val externalParentsAPI = externalParents.map(analysis.apis.externalAPI)
val internalParentsAPI = internalParents.map(analysis.apis.internalAPI)
val parentsHashes = (externalParentsAPI ++ internalParentsAPI).map(_.extraHash())
parentsHashes.fold(currentExtraHash)(_ ^ _)

We use parentsHashes.fold(currentExtraHash)(_ ^ _) which is a bad way to combine hashes together. If we use XOR to combine different hashes, identical hashes gets cancelled out. Since we are doing hierarchical hashing here I have a concern that such cancellation would happen.

Consider to replace with parentsHashes.hashCode instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant