Skip to content

Commit 06b8f74

Browse files
committed
C#: Avoid combinatorial explosion in structural comparison library
In cases where the target of a call/access has multiple values (which is a DB inconsistency), the GVN construction underlying the structural comparision library may run into a combinatorial explosion. This change excludes such expressions from the GVN construction.
1 parent 5c04516 commit 06b8f74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

csharp/ql/lib/semmle/code/csharp/commons/StructuralComparison.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ private class GvnCons extends Gvn, TGvnCons {
8787
pragma[noinline]
8888
private predicate gvnKindDeclaration(Expr e, int kind, boolean isTargetThis, Declaration d) {
8989
isTargetThis = isTargetThis(e) and
90-
d = referenceAttribute(e) and
90+
// guard against elements with multiple declaration targets (DB inconsistency),
91+
// which may result in a combinatorial explosion
92+
d = unique(Declaration d0 | d0 = referenceAttribute(e) | d0) and
9193
expressions(e, kind, _)
9294
}
9395

0 commit comments

Comments
 (0)