From c465e14fb7f15e5b5f5e07956c73712aac0840fb Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 11 Oct 2019 14:14:28 -0400 Subject: [PATCH] Fix propagation of JumpdestCountAnnotation --- .../laser/ethereum/strategy/extensions/bounded_loops.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mythril/laser/ethereum/strategy/extensions/bounded_loops.py b/mythril/laser/ethereum/strategy/extensions/bounded_loops.py index 5a7583ab..bedbc139 100644 --- a/mythril/laser/ethereum/strategy/extensions/bounded_loops.py +++ b/mythril/laser/ethereum/strategy/extensions/bounded_loops.py @@ -3,7 +3,6 @@ from mythril.laser.ethereum.strategy.basic import BasicSearchStrategy from mythril.laser.ethereum.state.annotation import StateAnnotation from mythril.laser.ethereum.transaction import ContractCreationTransaction from typing import Dict, cast, List -from copy import copy import logging @@ -17,9 +16,7 @@ class JumpdestCountAnnotation(StateAnnotation): self._reached_count = {} # type: Dict[str, int] def __copy__(self): - result = JumpdestCountAnnotation() - result._reached_count = copy(self._reached_count) - return result + return self class BoundedLoopsStrategy(BasicSearchStrategy): @@ -48,7 +45,6 @@ class BoundedLoopsStrategy(BasicSearchStrategy): :return: Global state """ - while True: state = self.super_strategy.get_strategic_global_state() @@ -60,6 +56,7 @@ class BoundedLoopsStrategy(BasicSearchStrategy): if len(annotations) == 0: annotation = JumpdestCountAnnotation() + log.debug("Adding JumpdestCountAnnotation to GlobalState") state.annotate(annotation) else: annotation = annotations[0] @@ -74,7 +71,7 @@ class BoundedLoopsStrategy(BasicSearchStrategy): cur_instr["opcode"], cur_instr["address"], state.mstate.prev_pc ) - if key in annotation._reached_count: + if key in annotation._reached_count.keys(): annotation._reached_count[key] += 1 else: annotation._reached_count[key] = 1