Skip to content
17 changes: 17 additions & 0 deletions manticore/core/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ def __init__(
self._snapshot = None
self._main_id = os.getpid(), threading.current_thread().ident

# Make sure terminated workers are restarted
self.subscribe("did_terminate_worker", self.did_terminate_worker_callback)
self.last_id = self._workers[-1].id
self.number_killed_states = self.count_killed_states()

def is_main(self):
"""True if called from the main process/script
Note: in "single" mode this is _most likely_ True"""
Expand Down Expand Up @@ -1235,6 +1240,18 @@ def wait_for_log_purge(self):
break
time.sleep(0.25)

def did_terminate_worker_callback(self, id):
ks = self.count_killed_states()
new_number_killed_states = ks - self.number_killed_states
if new_number_killed_states > 0:
self.number_killed_states = ks
logger.warning("Found %d new killed states" % new_number_killed_states)
for _ in range(new_number_killed_states):
self.last_id = self.last_id + 1
w = self._worker_type(id=self.last_id, manticore=self)
self._workers.append(w)
w.start()

############################################################################
############################################################################
############################################################################
Expand Down
Loading