Project

General

Profile

Actions

Bug #20207

closed

Segmentation fault for a regexp containing positive and negative lookaheads

Added by Sundeep (Sundeep Agarwal) 4 months ago. Updated about 2 months ago.


Description

I'm getting segmentation fault for the following regexp with Ruby 3.3.0:

puts 'clan'.match?(/(?=.*a)(?!.*n)/)

This is the minimal example for which I was able to produce the issue. a and n in the above example
are just a sample, can be other character combinations too. There has to be at least two characters
before them in the input string (cl in the above example).

The error is seen when the above code is run from a file, but only occasionally from irb.
When run from a file, most of the time I get segmentation fault (see attached log file),
but sometimes I get the following error:

lookaround.rb:1:in `match?': undefined bytecode (bug): /(?=.*a)(?!.*n)/ (RegexpError)
	from lookaround.rb:1:in `<main>'

When asked in the r/ruby forum, somebody else was able to reproduce this issue.
They also mentioned that the issue wasn't seen in the Ruby 3.2.2 version.


Files

lookaround_segfault.log (15.9 KB) lookaround_segfault.log Sundeep (Sundeep Agarwal), 01/24/2024 08:31 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #20212: Regex match method is crashing - (irb):6: [BUG] Segmentation fault at 0x0000000000000000 ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]Closedmake_now_just (Hiroya Fujinami)Actions
Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0Like0Like0