Exiv2 / exiv2

Image metadata library and tools

Home Page:http://www.exiv2.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extreme slowdown due to use of std:regex on Windows (MSYS2 UCRT64)

Wormnest opened this issue · comments

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:

  1. File made for testing by me
    exiv2-iptc-regex-utc64-1
  2. 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.
  3. 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 :

  1. in DateValue::read the line static 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
  2. TimeValue::read, slowdowns observed both in
    • static 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