Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67b4516

Browse files
committed
Python: CG trace: Partial matching of BytecodeExpr and AST not safe
1 parent 1e89388 commit 67b4516

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ class XMLCall extends XMLElement {
7777
bytecode.(XMLBytecodeAttribute).get_object_data())
7878
or
7979
matchBytecodeExpr(expr.(Call).getFunc(), bytecode.(XMLBytecodeCall).get_function_data())
80-
// I experimented with allowing partial matches with
81-
// ```
82-
// or
83-
// bytecode instanceof XMLBytecodeUnknown
84-
// ```
85-
// but that only gave 1% improvement for Identified calls with approx 4200 calls
86-
// in total (only supporting BytecodeVariableName/BytecodeAttribute/BytecodeCall).
87-
// Since it's a potential performance problem, I did not enable.
80+
// I considered allowing a partial match as well. That is, if the bytecode
81+
// expression information only tells us `<unknown>.foo()`, and we find an AST
82+
// expression that matches on `.foo()`, that is good enough.
83+
//
84+
// However, we cannot assume that all calls are recorded (such as `range(10)`),
85+
// and we cannot assume that for all recorded calls there exists a corresponding
86+
// AST call (such as for list-comprehensions).
87+
//
88+
// So allowing partial matches is not safe, since we might end up matching a
89+
// recorded call not in the AST together with an unrecorded call visible in the
90+
// AST.
8891
)
8992
}
9093
}

0 commit comments

Comments
 (0)