Skip to content

Commit 4923326

Browse files
authored
Python: Fix bad join in getValue
We were building essentially a CP of all control flow nodes: ``` Tuple counts for Essa::AssignmentDefinition::getValue#dispred#f0820431#ff/2@dd1f67vl after 2m45s: 733365 ~6% {3} r1 = JOIN Essa::TEssaNodeDefinition#24e22a14#ffff_30#join_rhs WITH Essa::EssaNodeDefinition::getDefiningNode#dispred#f0820431#ff ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Rhs.0 376588 ~0% {2} r2 = JOIN r1 WITH SsaDefinitions::SsaSource::assignment_definition#9197156e#fff ON FIRST 2 OUTPUT Lhs.2 'this', Rhs.2 'result' 376588 ~0% {3} r3 = JOIN r2 WITH Essa::TEssaNodeDefinition#24e22a14#ffff_30#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.0 'this', Lhs.1 'result' 6965593033 ~2% {3} r4 = JOIN r3 WITH project#SsaDefinitions::SsaSource::assignment_definition#9197156e ON FIRST 1 OUTPUT Lhs.1 'this', Rhs.1, Lhs.2 'result' 376588 ~0% {2} r5 = JOIN r4 WITH Essa::EssaNodeDefinition::getDefiningNode#dispred#f0820431#ff ON FIRST 2 OUTPUT Lhs.0 'this', Lhs.2 'result' return r5 ``` We first tried preventing the join on `result`, but this caused the characteristic predicate to blow up instead. Finally, we figured just putting the `value` part in a field would be sufficient, and this did the trick.
1 parent 60eb341 commit 4923326

File tree

1 file changed

+4
-4
lines changed
  • python/ql/lib/semmle/python/essa

1 file changed

+4
-4
lines changed

python/ql/lib/semmle/python/essa/Essa.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ private EssaVariable potential_input(EssaNodeRefinement ref) {
498498

499499
/** An assignment to a variable `v = val` */
500500
class AssignmentDefinition extends EssaNodeDefinition {
501+
ControlFlowNode value;
502+
501503
AssignmentDefinition() {
502-
SsaSource::assignment_definition(this.getSourceVariable(), this.getDefiningNode(), _)
504+
SsaSource::assignment_definition(this.getSourceVariable(), this.getDefiningNode(), value)
503505
}
504506

505-
ControlFlowNode getValue() {
506-
SsaSource::assignment_definition(this.getSourceVariable(), this.getDefiningNode(), result)
507-
}
507+
ControlFlowNode getValue() { result = value }
508508

509509
override string getRepresentation() { result = this.getValue().getNode().toString() }
510510

0 commit comments

Comments
 (0)