Project

General

Profile

Actions

Bug #18144

closed

Timeout not working while regular expression match is running

Added by duerst (Martin Dürst) over 3 years ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
various, see description
[ruby-core:105116]

Description

Experimenting with dozens of regular expressions that take a long time to match against certain strings, I have found that for some regular expression matches, Timeouts don't work at all (while they work for the rest without problems).

The attached file allows reproduction. On three different machines and with six different versions of Ruby (see below), the attached file always showed about 20~25 seconds of execution time even though there was a Timeout interval of only 10s. If your machine is too fast so that the printed-out result comes in below or just a bit above 10s, then either lower the timeout duration (e.g. to 5s) or increase the length of the string (e.g. 80_000 -> 100_000; caution, time increases with the second power of this number).

The timeout uses Timeout::timeout and rescue Timeout::Error as described in the pickaxe.

Checked with the following versions/environments:

  • ruby 3.1.0dev (2021-06-03T06:59:33Z master 7e14762159) [x86_64-linux] on Ubuntu on WSL on a Windows 10 notebook
  • ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-cygwin] on same notebook
  • ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32] on same notebook
  • ruby 3.1.0dev (2021-06-03T06:59:33Z master 7e14762159) [x86_64-linux] on Ubuntu on WSL on same notebook
  • ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu] on a two-CPU Dell server with Ubuntu
  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] on an older Dell server with CentOS

Files

no_timeout.rb (333 Bytes) no_timeout.rb duerst (Martin Dürst), 09/02/2021 06:44 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #17837: Add support for Regexp timeoutsClosedActions
Actions #1

Updated by duerst (Martin Dürst) over 3 years ago

Actions #2

Updated by duerst (Martin Dürst) over 3 years ago

  • Status changed from Third Party's Issue to Open

Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  • Status changed from Open to Closed

This issue appears fixed in Ruby 3.2, due to regexp optimizations by @makenowjust. If there are regexps that are still experiencing this issue, please report them and we can reopen.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0