Extreme slowdown due to use of std:regex on Windows (MSYS2 UCRT64)
Wormnest opened this issue · comments
jacobb commented
Describe the bug
This is a follow-up of issue 2831. In this case it concerns the std:regex used in the reading of IPTC date and time values.
To Reproduce
Steps to reproduce the behavior:
- File made for testing by me
- Start UCRT64 MSYS2 gimp3 or self-built gimp master with up-to-date exiv2 package for UCRT64 (0.28.1-2) that includes the previous regex patch.
- Open the above image and notice extreme slowdown and huge memory use.
Expected behavior
GIMP finishing opening the image in a short time.
Desktop (please complete the following information):
- OS and version: Windows 10 Home, 64-bit
- Exiv2 version and source: see above, but also self-built under MSYS2 UCRT64 with added printf statements to see where the slowdowns happened
- Compiler and version: gcc 13.2.0
- Compilation mode and/or compiler flags: Release
Additional context
By adding printf statements I observed the slowdowns this time in src/value.cpp
:
- in
DateValue::read
the linestatic const std::regex reExtended(R"(^(\d{4})-(\d{2})-(\d{2}))");
possibly also the next line but I had to walk away for a while and when I came back it was in TimeValue::read
, slowdowns observed both instatic const std::regex re(R"(^(2[0-3]|[01][0-9]):?([0-5][0-9])?:?([0-5][0-9])?$)");
static const std::regex reExt( R"(^(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])(Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?)$)");
I then gave up waiting, must have been close to half an hour at least.
Note: there seem to be a few more places using regex that may or may not be affected
Miloš Komarčević commented