From 8e0b9f495b1967bf7503bfe4e66687955eee1922 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 3 Oct 2017 00:24:32 +0300 Subject: [PATCH] tests/extmod: Add test for ure regexes leading to infinite recursion. These now should be caught properly and lead to RuntimeError instead of crash. --- tests/extmod/ure_stack_overflow.py | 13 +++++++++++++ tests/extmod/ure_stack_overflow.py.exp | 1 + 2 files changed, 14 insertions(+) create mode 100644 tests/extmod/ure_stack_overflow.py create mode 100644 tests/extmod/ure_stack_overflow.py.exp diff --git a/tests/extmod/ure_stack_overflow.py b/tests/extmod/ure_stack_overflow.py new file mode 100644 index 000000000..d3ce0c5a7 --- /dev/null +++ b/tests/extmod/ure_stack_overflow.py @@ -0,0 +1,13 @@ +try: + import ure as re +except ImportError: + try: + import re + except ImportError: + print("SKIP") + raise SystemExit + +try: + re.match("(a*)*", "aaa") +except RuntimeError: + print("RuntimeError") diff --git a/tests/extmod/ure_stack_overflow.py.exp b/tests/extmod/ure_stack_overflow.py.exp new file mode 100644 index 000000000..8a2b9bfdd --- /dev/null +++ b/tests/extmod/ure_stack_overflow.py.exp @@ -0,0 +1 @@ +RuntimeError