Project

General

Profile

Actions

Bug #14103

open

Regexp absense operator has no chance to ^C

Added by shyouhei (Shyouhei Urabe) almost 4 years ago. Updated 2 days ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-11-09 trunk 60720) [x86_64-darwin15]
[ruby-core:83750]
Tags:

Description

Following script hangs, with no respond to ^C.

/(?<x> (?<! a ) a+ ){0}
 (?<y> (?~ \g<z> ) ){0}
 (?<z> (?<! a ) \k<x> (?! a ) ){0}
 \g<x> \g<y> \g<z>
/xo =~ (1..1024).map{|x| 'b' + 'a' * x }.join

Updated by jeremyevans0 (Jeremy Evans) 2 days ago

I submitted a pull request to fix this: https://github.com/ruby/ruby/pull/4960

The issue is unlikely to be specific to the absence operator, I think it affects any case where a regexp takes a long time due to backtracking. In addition to allowing interrupts, the pull request also allows yielding to other threads during a long regexp match (since checking for interrupts has that effect).

Actions

Also available in: Atom PDF