https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-04-27T09:51:23ZRuby Issue Tracking SystemRuby 1.8 - Bug #6366: Regex freezes Rubyhttps://bugs.ruby-lang.org/issues/6366?journal_id=262322012-04-27T09:51:23Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>=begin<br>
It's due to the bad regexp.</p>
<p>You should not repeat repetitive operators (({"([\w_]*)+?"})), which causes combinatorial explosion.</p>
<p>Try with (({"([\w_]+?)"})).<br>
=end</p> Ruby 1.8 - Bug #6366: Regex freezes Rubyhttps://bugs.ruby-lang.org/issues/6366?journal_id=262372012-04-27T12:36:49Zvertis (Luke Chadwick)luke.a.chadwick@gmail.com
<ul></ul><p>Sure, that works. You're absolutely correct about my regex error.</p>
<p>However, I still think it's a bug. The behaviour should be to fail with an Exception not lockup indefinitely.</p> Ruby 1.8 - Bug #6366: Regex freezes Rubyhttps://bugs.ruby-lang.org/issues/6366?journal_id=262452012-04-27T14:31:43Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>No, sorry. You <em>cant</em> detect whether your program locks up.</p>
<p><a href="http://en.wikipedia.org/wiki/Halting_problem" class="external">http://en.wikipedia.org/wiki/Halting_problem</a></p> Ruby 1.8 - Bug #6366: Regex freezes Rubyhttps://bugs.ruby-lang.org/issues/6366?journal_id=262712012-04-28T08:47:26Zvertis (Luke Chadwick)luke.a.chadwick@gmail.com
<ul></ul><p>Right, but you could detect bad patterns in the regex like the double repetition. How does Ruby 1.9 NOT freeze?</p> Ruby 1.8 - Bug #6366: Regex freezes Rubyhttps://bugs.ruby-lang.org/issues/6366?journal_id=262872012-04-28T19:31:08Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Oniguruma, the regex engine in 1.9, optimizes it in its parser.<br>
But 1.8 doesn't, and has no future.</p>