[#105450] [Ruby master Feature#18228] Add a `timeout` option to `IO.copy_stream` — "byroot (Jean Boussier)" <noreply@...>
SXNzdWUgIzE4MjI4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku
11 messages
2021/09/27
[ruby-core:105116] [Ruby master Bug#18144] Timeout not working while regular expression match is running
From:
duerst <noreply@...>
Date:
2021-09-02 07:05:19 UTC
List:
ruby-core #105116
Issue #18144 has been reported by duerst (Martin D=FCrst). ---------------------------------------- Bug #18144: Timeout not working while regular expression match is running https://bugs.ruby-lang.org/issues/18144 * Author: duerst (Martin D=FCrst) * Status: Third Party's Issue * Priority: Normal * ruby -v: various, see description * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Experimenting with dozens of regular expressions that take a long time to m= atch 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 showe= d about 20~25 seconds of execution time even though there was a Timeout int= erval of only 10s. If your machine is too fast so that the printed-out resu= lt comes in below or just a bit above 10s, then either lower the timeout du= ration (e.g. to 5s) or increase the length of the string (e.g. 80_000 -> 10= 0_000; caution, time increases with the second power of this number). The timeout uses `Timeout::timeout` and `rescue Timeout::Error` as describe= d 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 notebo= ok - ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32] on same noteb= ook - 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) -- = https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>