libassert icon indicating copy to clipboard operation
libassert copied to clipboard

Runtime error with regular expressions in libc++

Open jeremy-rifkin opened this issue 2 years ago • 3 comments

terminating with uncaught exception of type std::__1::regex_error: The expression contained an invalid back reference.
zsh: abort      ./a.out

Thrown on line 1080 https://github.com/jeremy-rifkin/libassert/blob/39a1babf70585e4b2e2361adc257da3ed6ae792e/src/assert.cpp#L1074-L1081

jeremy-rifkin avatar May 09 '22 07:05 jeremy-rifkin

The problematic regex is ^((?:(?:u8|[UuL])?'(?:\\[0-7]{1,3}|\\x[\da-fA-F]+|\\.|[^\n'])*')|(?:(?:u8|[UuL])?R"([^ ()\\t\r\v\n]*)\((?:(?!\)\2\").)*\)\2")|(?:(?:u8|[UuL])?"(?:\\[0-7]{1,3}|\\x[\da-fA-F]+|\\.|[^\n"])*"))[^]*

jeremy-rifkin avatar May 09 '22 07:05 jeremy-rifkin

Minimal reproducible regex is (x*)\s+(?!\1).+ https://godbolt.org/z/3h1hfrGeP

jeremy-rifkin avatar May 09 '22 16:05 jeremy-rifkin

(For future reference: Reported at https://github.com/llvm/llvm-project/issues/55357)

jeremy-rifkin avatar Mar 27 '23 20:03 jeremy-rifkin