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

added the worker termination reinstantiation code #2597

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions manticore/core/manticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def __init__(

self._snapshot = None
self._main_id = os.getpid(), threading.current_thread().ident
#restarting the workers
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
Expand Down Expand Up @@ -1235,6 +1239,31 @@ def wait_for_log_purge(self):
break
time.sleep(0.25)

#Method to cehck for the workers termination after they have completed the tasks.
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()

def initialize_terminated_workers(self) -> typing.Dict[int, StateDescriptor]:
"""
Allows callers to view descriptors for each state

:return: the latest copy of the State Descriptor dict
"""
key = IntrospectionAPIPlugin.NAME
if key in self.plugins:
plug: IntrospectionAPIPlugin = self.plugins[key]
return plug.get_state_descriptors()
return {}

############################################################################
############################################################################
############################################################################
Expand Down