From 20bb82fce6146dba2b11c7cc7f0b21050d152661 Mon Sep 17 00:00:00 2001 From: Don Kirkby Date: Thu, 12 Oct 2023 20:52:40 -0700 Subject: [PATCH 1/3] Add a bug that will break fuzz testing. --- plugin/PySrc/space_tracer/code_tracer.py | 1 + plugin/PySrc/space_tracer/main.py | 1 + 2 files changed, 2 insertions(+) diff --git a/plugin/PySrc/space_tracer/code_tracer.py b/plugin/PySrc/space_tracer/code_tracer.py index f69f0f80..2b57fa0b 100644 --- a/plugin/PySrc/space_tracer/code_tracer.py +++ b/plugin/PySrc/space_tracer/code_tracer.py @@ -421,6 +421,7 @@ def visit_For(self, node): args = [Constant(min(line_numbers)), Constant(max(line_numbers))] new_body = [self._create_context_call('start_block', args)] + 1/0 new_body.extend(self._trace_assignment_list(new_node.target)) new_body.extend(new_node.body) new_node.body = new_body diff --git a/plugin/PySrc/space_tracer/main.py b/plugin/PySrc/space_tracer/main.py index 1491e336..749679ef 100644 --- a/plugin/PySrc/space_tracer/main.py +++ b/plugin/PySrc/space_tracer/main.py @@ -484,6 +484,7 @@ def trace_command(self, command_args=None): builder.add_message(str(ex), 1) self.return_code = 1 except BaseException as ex: + raise self.return_code = getattr(ex, 'code', 1) etype, value, tb = sys.exc_info() is_reported = False From a4d041129063d9aafaf1fa01a00d3e151136e8b4 Mon Sep 17 00:00:00 2001 From: Don Kirkby Date: Fri, 13 Oct 2023 20:13:21 -0700 Subject: [PATCH 2/3] Break fuzz testing without breaking unit tests. --- plugin/PySrc/space_tracer/code_tracer.py | 7 ++++++- plugin/PySrc/space_tracer/main.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/PySrc/space_tracer/code_tracer.py b/plugin/PySrc/space_tracer/code_tracer.py index 2b57fa0b..072e8dbe 100644 --- a/plugin/PySrc/space_tracer/code_tracer.py +++ b/plugin/PySrc/space_tracer/code_tracer.py @@ -54,6 +54,9 @@ def find_line_numbers(node, line_numbers): # noinspection PyPep8Naming class Tracer(NodeTransformer): + def __init__(self): + self.for_count = 0 + @staticmethod def _set_statement_line_numbers(statements, previous_line_number=None): @@ -421,7 +424,9 @@ def visit_For(self, node): args = [Constant(min(line_numbers)), Constant(max(line_numbers))] new_body = [self._create_context_call('start_block', args)] - 1/0 + self.for_count += 1 + if self.for_count >= 3: + raise FloatingPointError('Oops.') new_body.extend(self._trace_assignment_list(new_node.target)) new_body.extend(new_node.body) new_node.body = new_body diff --git a/plugin/PySrc/space_tracer/main.py b/plugin/PySrc/space_tracer/main.py index 749679ef..ca6b4632 100644 --- a/plugin/PySrc/space_tracer/main.py +++ b/plugin/PySrc/space_tracer/main.py @@ -483,8 +483,9 @@ def trace_command(self, command_args=None): except SourceLoadError as ex: builder.add_message(str(ex), 1) self.return_code = 1 - except BaseException as ex: + except FloatingPointError: raise + except BaseException as ex: self.return_code = getattr(ex, 'code', 1) etype, value, tb = sys.exc_info() is_reported = False From a14da9e19b3e2fd17605c69943ddb41da36c9706 Mon Sep 17 00:00:00 2001 From: Don Kirkby Date: Fri, 13 Oct 2023 21:02:23 -0700 Subject: [PATCH 3/3] Tweak message. --- plugin/PySrc/space_tracer/code_tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/PySrc/space_tracer/code_tracer.py b/plugin/PySrc/space_tracer/code_tracer.py index 072e8dbe..786247a3 100644 --- a/plugin/PySrc/space_tracer/code_tracer.py +++ b/plugin/PySrc/space_tracer/code_tracer.py @@ -426,7 +426,7 @@ def visit_For(self, node): new_body = [self._create_context_call('start_block', args)] self.for_count += 1 if self.for_count >= 3: - raise FloatingPointError('Oops.') + raise FloatingPointError('Oops, I did it again.') new_body.extend(self._trace_assignment_list(new_node.target)) new_body.extend(new_node.body) new_node.body = new_body