Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
add tracking of existing threadIds and threadCreations.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfriedberger committed Dec 8, 2020
1 parent b876898 commit fecd3d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lint/witnesslint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
NO_PROGRAM = 6
INTERNAL_ERROR = 7

MAIN_THREAD_ID = '0'


def create_linter(argv):
arg_parser = create_arg_parser()
Expand Down Expand Up @@ -446,6 +448,7 @@ def handle_edge_data(self, data, key, parent):
break
self.check_functionname(data.text, data.sourceline)
elif key == witness.THREADID:
self.witness.thread_ids.add(data.text)
# Check disabled for SV-COMP'21 as questions about the specification
# need to be resolved first, see
# https://gitlab.com/sosy-lab/sv-comp/archives-2021/-/issues/30
Expand All @@ -456,6 +459,7 @@ def handle_edge_data(self, data, key, parent):
# )
pass
elif key == witness.CREATETHREAD:
self.witness.thread_creations.add(data.text)
if data.text in self.witness.threads:
logging.warning(
"Thread with id {} has already been created".format(data.text),
Expand Down Expand Up @@ -867,6 +871,9 @@ def final_checks(self):
collections.OrderedDict(sorted(self.witness.transitions.items())),
self.witness.entry_node,
)
spare_thread_ids = self.witness.thread_ids - self.witness.thread_creations - set(MAIN_THREAD_ID)
if spare_thread_ids:
logging.warning("Threads were executed, but never created: {}".format(spare_thread_ids))
if self.program_info is not None:
for check in self.check_later:
check()
Expand Down
2 changes: 2 additions & 0 deletions lint/witnesslint/witness.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def __init__(self, witness_file):
self.defined_keys = {}
self.used_keys = set()
self.threads = {}
self.thread_creations = set()
self.thread_ids = set()
self.transition_sources = set()
self.transitions = {}

Expand Down

0 comments on commit fecd3d8

Please sign in to comment.