Skip to content

Commit 2be9f3e

Browse files
committed
C#: Guard against virtual dispatch branching too much.
We have observed databases where dispatch to highly overridden virtual methots (like Enumerable.GetEnumerator) ends up branching to many thousands of overrides, if there is not sufficient type context to prune. This causes performance problems for analyses that use dataflow. As an immediate fix, this commit prevents branching to virtual method overrides if this would result in branching to 1,000 or more methods.
1 parent 26881ec commit 2be9f3e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

csharp/ql/src/semmle/code/csharp/dispatch/Dispatch.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private module Internal {
508508
override RuntimeCallable getADynamicTarget() {
509509
result = getAViableInherited()
510510
or
511-
result = getAViableOverrider()
511+
result = getAViableOverrider() and strictcount(getAViableOverrider()) < 1000
512512
or
513513
// Simple case: target method cannot be overridden
514514
result = getAStaticTarget() and

0 commit comments

Comments
 (0)