ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103730] Re: [Ruby master Feature#17837] Add support for Regexp timeouts
Date: Wed, 5 May 2021 05:28:14 +0000	[thread overview]
Message-ID: <20210505052814.GA17488@dcvr> (raw)
In-Reply-To: <redmine.issue-17837.20210427233953.5660@ruby-lang.org>

sam.saffron@gmail.com wrote:
> Feature #17837: Add support for Regexp timeouts
> https://bugs.ruby-lang.org/issues/17837

> I recommend against a "per Regexp" API as this decision is at
> the application level. You want to apply it to all regular
> expressions in all the gems you are consuming.

The syscall costs are higher nowadays and this will penalize
good regexps.  IME with unicorn, global timeouts of this type
means problems go unfixed for too long and fester into worse
problems.

Ultimately many Ruby problems come from tolerating excessively
deep/complex dependency stacks(*) and developers having too
much crap to manage.

Anecdotally, my experience with Perl5 RE is better than with
Onig*.  I know Perl5 has the same underlying problems as Onig*,
however Perl5 RE seems less bad in practice.

Again, Perl5 RE does have underlying problems, but they don't
manifest nearly as much as they do with Ruby (I've as much
or more Perl experience than I have in Ruby).

One example I remember off the top of my head is
[ruby-core:74030].   I just tested that again after 5 years:
Ruby still infinite loops; Perl still terminates as it should.

Your example translated to Perl5 also stops fine for me:

	("A" . "C" x 100 . "X") =~ /A(B|C+)+D/;

Onig* might be able to learn a thing or three from Perl5 when it
comes to common real-world cases.  Again, I know Perl5 RE has
underlying problems just like Onig*, they do not manifest as
easily.


(*) and I apologize for letting crap like unicorn become too
    popular and perpetuating the existence of of buggy/broken
    code; I'll try to find more time to scare users away from it.

> I recommend against a move to RE2 at the moment as way too
> much would break 

RE2 could be done gradually, like frozen strings: %re2[foo]
Or a magic comment: "# regexp-engine: re2"

Perl supports pluggable re::engine since 2007, so more things
Ruby can learn from Perl :>
```

  parent reply	other threads:[~2021-05-05  5:28 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 23:39 [ruby-core:103631] [Ruby master Feature#17837] Add support for Regexp timeouts sam.saffron
2021-04-28  5:23 ` [ruby-core:103636] " mame
2021-04-28  7:25 ` [ruby-core:103639] " sam.saffron
2021-04-29  5:23 ` [ruby-core:103652] " mame
2021-04-29 13:05 ` [ruby-core:103655] " daniel
2021-04-30 20:29 ` [ruby-core:103676] " eregontp
2021-05-03  7:58 ` [ruby-core:103696] " sam.saffron
2021-05-03 13:38 ` [ruby-core:103700] " mame
2021-05-03 14:57 ` [ruby-core:103701] " jean.boussier
2021-05-04  0:12 ` [ruby-core:103705] " duerst
2021-05-04 10:31 ` [ruby-core:103710] " eregontp
2021-05-04 12:55 ` [ruby-core:103711] " daniel
2021-05-04 14:22 ` [ruby-core:103713] " jean.boussier
2021-05-05  2:02 ` [ruby-core:103725] " duerst
2021-05-05  5:28 ` Eric Wong [this message]
2021-05-06 13:30 ` [ruby-core:103760] " daniel
2021-05-06 15:20 ` [ruby-core:103761] " eregontp
2021-05-07  6:03 ` [ruby-core:103769] " nobu
2021-05-07  7:57 ` [ruby-core:103770] " mame
2021-05-07  8:14 ` [ruby-core:103771] " sam.saffron
2021-05-11  7:33 ` [ruby-core:103780] " sam.saffron
2021-05-11 11:25 ` [ruby-core:103784] " mame
2021-05-11 12:23 ` [ruby-core:103785] " nobu
2021-05-11 22:22 ` [ruby-core:103789] " sam.saffron
2021-05-11 22:23 ` [ruby-core:103790] " sam.saffron
2021-05-12 15:13 ` [ruby-core:103800] " get.codetriage
2021-05-12 22:18 ` [ruby-core:103809] " daniel
2021-05-21 18:00 ` [ruby-core:103953] " mame
2021-07-14 11:59 ` [ruby-core:104598] " duerst
2021-10-17 13:55 ` [ruby-core:105656] " Dan0042 (Daniel DeLorme)
2021-10-25  3:09 ` [ruby-core:105770] " mame (Yusuke Endoh)
2021-10-25  4:26 ` [ruby-core:105772] " mame (Yusuke Endoh)
2021-10-25  4:39 ` [ruby-core:105773] " mame (Yusuke Endoh)
2021-10-25 11:17 ` [ruby-core:105787] " Eregon (Benoit Daloze)
2021-10-25 16:42 ` [ruby-core:105791] " mame (Yusuke Endoh)
2021-10-25 17:21 ` [ruby-core:105793] " Dan0042 (Daniel DeLorme)
2022-03-22  6:45 ` [ruby-core:108015] " mame (Yusuke Endoh)
2022-03-22 10:12 ` [ruby-core:108017] " Eregon (Benoit Daloze)
2022-03-22 13:55 ` [ruby-core:108023] " Dan0042 (Daniel DeLorme)
2022-03-23  0:21 ` [ruby-core:108029] " mame (Yusuke Endoh)
2022-03-23 14:38 ` [ruby-core:108041] " Eregon (Benoit Daloze)
2022-03-28  5:15 ` [ruby-core:108094] " mame (Yusuke Endoh)
2022-03-28  6:04 ` [ruby-core:108096] " mame (Yusuke Endoh)
2022-03-28 10:19 ` [ruby-core:108098] " Eregon (Benoit Daloze)
2022-03-30  1:22 ` [ruby-core:108116] " mame (Yusuke Endoh)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505052814.GA17488@dcvr \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).