From 171f3374c7668e1e108d5c699ff0ee815967525c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= Date: Thu, 30 Oct 2025 19:52:11 +0100 Subject: [PATCH 1/4] align x64's max stack limit with x86's --- stl/inc/regex | 4 ---- tests/std/tests/VSO_0000000_regex_use/test.cpp | 13 +++++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/stl/inc/regex b/stl/inc/regex index 2409ce9bd5a..7b5fccb59cb 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -48,11 +48,7 @@ _STL_DISABLE_CLANG_WARNINGS #endif // !defined(_REGEX_MAX_COMPLEXITY_COUNT) #ifndef _REGEX_MAX_STACK_COUNT -#ifdef _WIN64 -#define _REGEX_MAX_STACK_COUNT 600L // set to 0 to disable -#else // ^^^ defined(_WIN64) / !defined(_WIN64) vvv #define _REGEX_MAX_STACK_COUNT 1000L // set to 0 to disable -#endif // ^^^ !defined(_WIN64) ^^^ #endif // !defined(_REGEX_MAX_STACK_COUNT) #ifndef _ENHANCED_REGEX_VISUALIZER diff --git a/tests/std/tests/VSO_0000000_regex_use/test.cpp b/tests/std/tests/VSO_0000000_regex_use/test.cpp index 794e3ffd06f..c24d5553024 100644 --- a/tests/std/tests/VSO_0000000_regex_use/test.cpp +++ b/tests/std/tests/VSO_0000000_regex_use/test.cpp @@ -910,12 +910,12 @@ void test_gh_997() { assert(ex.code() == error_stack); } - wregex rgx(LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase); + { + test_wregex rgx(&g_regexTester, LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase); - assert(regex_match(L"https://www.example.com/meow", rgx)); + rgx.should_search_match(L"https://www.example.com/meow", L"https://www.example.com/meow"); - try { - assert(!regex_match( + rgx.should_search_fail( L"https://www.bogus.invalid/" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" @@ -923,10 +923,7 @@ void test_gh_997() { L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456.89-123456789-123456789." L"123456789-12345678.-123456789-123456789-1.3456789-123456789-123456789-123456789-123456789-123456789-" - L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234", - rgx)); - } catch (const regex_error& ex) { - assert(ex.code() == error_stack); + L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234"); } } From 699b8fbcef6bb6a0b88f160243de215436e55f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= Date: Thu, 30 Oct 2025 19:56:38 +0100 Subject: [PATCH 2/4] remove default arguments from `_Matcher3::_Push_frame()` --- stl/inc/regex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/regex b/stl/inc/regex index 7b5fccb59cb..ea4447380de 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -1810,7 +1810,7 @@ private: vector<_Rx_state_frame_t<_It>> _Frames; size_t _Frames_count; - size_t _Push_frame(_Rx_unwind_ops _Code = {}, _Node_base* _Node = nullptr); + size_t _Push_frame(_Rx_unwind_ops _Code, _Node_base* _Node); void _Pop_frame(size_t); void _Increase_stack_usage_count(); @@ -3990,7 +3990,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N auto& _Sav = _Loop_vals[_Node->_Loop_number]; if (_Node->_Simple_loop == 1) { - _Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing); + _Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing, nullptr); _Increase_complexity_count(); if (_Node->_Min > 0 || (_Greedy && !_Longest && _Node->_Max != 0)) { // try a rep first _Sav._Loop_idx = 1; From c55ceb30e6d624321b9d71154ad5a97cd645f230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= Date: Thu, 30 Oct 2025 19:59:19 +0100 Subject: [PATCH 3/4] start unwinding opcodes at 1 --- stl/inc/regex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/regex b/stl/inc/regex index ea4447380de..b5bddf972b5 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -1671,7 +1671,7 @@ public: }; enum class _Rx_unwind_ops { - _After_assert = _N_end + 1, + _After_assert = 1, _After_neg_assert, _Disjunction_eval_alt_on_failure, _Disjunction_eval_alt_always, From ce3ccf9e14bf726e49d1b536694cc67e7c51ff6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller?= Date: Thu, 30 Oct 2025 20:01:16 +0100 Subject: [PATCH 4/4] remove `_Initial_frames_count` from `_Matcher3::_Match_pat()` --- stl/inc/regex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stl/inc/regex b/stl/inc/regex index b5bddf972b5..489dbf34f42 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -3814,8 +3814,7 @@ template bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _Nx) { // check for match _Increase_stack_usage_count(); - bool _Failed = false; - const size_t _Initial_frames_count = _Frames_count; + bool _Failed = false; while (_Nx) { do { // match current node @@ -4175,7 +4174,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N } } while (_Nx); - while (_Frames_count > _Initial_frames_count && !_Nx) { + while (_Frames_count > 0 && !_Nx) { auto& _Frame = _Frames[--_Frames_count]; switch (_Frame._Code) {