From 4814e8184be7344416f8b3352d30da224f143aec Mon Sep 17 00:00:00 2001 From: Joe Ranweiler Date: Wed, 14 Feb 2018 17:21:17 -0800 Subject: [PATCH] Flag unknown Manticore state terminations as crashes This is an over-approximation, which we will tighten later. --- bin/deepstate/main_manticore.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/deepstate/main_manticore.py b/bin/deepstate/main_manticore.py index 88ec543..b2aa623 100644 --- a/bin/deepstate/main_manticore.py +++ b/bin/deepstate/main_manticore.py @@ -130,6 +130,10 @@ class DeepManticore(DeepState): super(DeepManticore, self).pass_test() raise TerminateState(OUR_TERMINATION_REASON, testcase=False) + def crash_test(self): + super(DeepManticore, self).crash_test() + raise TerminateState(OUR_TERMINATION_REASON, testcase=False) + def fail_test(self): super(DeepManticore, self).fail_test() raise TerminateState(OUR_TERMINATION_REASON, testcase=False) @@ -184,6 +188,9 @@ def hook_Pass(state): """Implements DeepState_Pass, which notifies us of a passing test.""" DeepManticore(state).api_pass() +def hook_Crash(state): + """Implements DeepState_Crash, which notifies us of a crashing test.""" + DeepManticore(state).api_crash() def hook_Fail(state): """Implements DeepState_Fail, which notifies us of a failing test.""" @@ -238,11 +245,13 @@ def hook(func): def done_test(_, state, state_id, reason): """Called when a state is terminated.""" - if OUR_TERMINATION_REASON not in reason: - L.error("State {} terminated for unknown reason: {}".format( - state_id, reason)) - return mc = DeepManticore(state) + + if OUR_TERMINATION_REASON not in reason: + L.info("State {} terminated for unknown reason, treating as crash: {}".format( + state_id, reason)) + super(DeepManticore, mc).crash_test() + mc.report() @@ -280,6 +289,7 @@ def do_run_test(state, apis, test): m.add_hook(apis['MaxUInt'], hook(hook_MaxUInt)) m.add_hook(apis['Assume'], hook(hook_Assume)) m.add_hook(apis['Pass'], hook(hook_Pass)) + m.add_hook(apis['Crash'], hook(hook_Crash)) m.add_hook(apis['Fail'], hook(hook_Fail)) m.add_hook(apis['SoftFail'], hook(hook_SoftFail)) m.add_hook(apis['Abandon'], hook(hook_Abandon))