Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/timeout #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion angrop/rop_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ def _concretize_chain_values(self, constraints=None, timeout=None, preserve_next
concretize chain values with a timeout
"""
if self.next_pc_idx() is not None:
return (self + self._rop.chain_builder.shift(self._p.arch.bytes))._concretize_chain_values(constraints=constraints, timeout=timeout, preserve_next_pc=preserve_next_pc)
# make sure we don't leave a dangling `next_pc` value in the chain
# which may corrupt chain concatenation at byte-level
full_chain = self + self._rop.chain_builder.shift(self._p.arch.bytes)
return full_chain._concretize_chain_values( constraints=constraints,
timeout=timeout,
preserve_next_pc=preserve_next_pc)
if timeout is None:
timeout = self._timeout
values = rop_utils.timeout(timeout)(self.__concretize_chain_values)(constraints=constraints)
Expand Down
8 changes: 8 additions & 0 deletions angrop/rop_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ def step_to_unconstrained_successor(project, state, max_steps=2, allow_simproced
def timeout(seconds_before_timeout):
def decorate(f):
def handler(signum, frame):# pylint:disable=unused-argument
# Exception during __del__ will be ignore
# so if we happen to hit a __del__, retry the alarm
# reference: https://docs.python.org/3/reference/datamodel.html#object.__del__
while frame.f_back:
if frame.f_code.co_name == '__del__':
signal.setitimer(signal.ITIMER_REAL, 0.1, 0)
return
frame = frame.f_back
print("[angrop] Timeout")
raise RopException("[angrop] Timeout!")
def new_f(*args, **kwargs):
Expand Down