ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "byroot (Jean Boussier) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "byroot (Jean Boussier)" <noreply@ruby-lang.org>
Subject: [ruby-core:116408] [Ruby master Bug#20207] Segmentation fault for a regexp containing positive and negative lookaheads
Date: Wed, 24 Jan 2024 12:11:37 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-106430.20240124121136.13711@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20207.20240124084157.13711@ruby-lang.org

Issue #20207 has been updated by byroot (Jean Boussier).


@nobu I do get a SEGV on both x86_64 and ARM64:

```
-- C level backtrace information -------------------------------------------
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(rb_vm_bugreport+0xb4c) [0x100fd6534]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(rb_bug_for_fatal_signal+0x100) [0x100e197c8]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(sig_do_nothing+0x0) [0x100f3e14c]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x18494da24]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(match_at+0x21dc) [0x100f1d744]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(onig_search_gpos+0x694) [0x100f25b04]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(rb_reg_match_p+0x1cc) [0x100f09448]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(vm_call_cfunc_with_frame_+0xf0) [0x100fc9228]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(vm_exec_core+0x2048) [0x100faef80]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(rb_vm_exec+0x1ec) [0x100fabdc4]
/opt/rubies/3.3.0/lib/libruby.3.3.dylib(rb_f_eval+0x1d8) [0x100fbaf7c]
```

----------------------------------------
Bug #20207: Segmentation fault for a regexp containing positive and negative lookaheads
https://bugs.ruby-lang.org/issues/20207#change-106430

* Author: Sundeep (Sundeep Agarwal)
* Status: Open
* Priority: Normal
* Assignee: make_now_just (Hiroya Fujinami)
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
I'm getting segmentation fault for the following regexp with Ruby 3.3.0:

``` ruby
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:

``` ruby
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)


-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

  parent reply	other threads:[~2024-01-24 12:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  8:41 [ruby-core:116395] [Ruby master Bug#20207] Segmentation fault for a regexp containing positive and negative lookaheads Sundeep (Sundeep Agarwal) via ruby-core
2024-01-24 10:23 ` [ruby-core:116400] " mame (Yusuke Endoh) via ruby-core
2024-01-24 11:06 ` [ruby-core:116402] " nobu (Nobuyoshi Nakada) via ruby-core
2024-01-24 12:11 ` byroot (Jean Boussier) via ruby-core [this message]
2024-01-24 12:13 ` [ruby-core:116409] " byroot (Jean Boussier) via ruby-core
2024-01-24 23:27 ` [ruby-core:116432] " alanwu (Alan Wu) via ruby-core
2024-03-20 23:17 ` [ruby-core:117269] " naruse (Yui NARUSE) via ruby-core

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=redmine.journal-106430.20240124121136.13711@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    --cc=ruby-core@ml.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).