ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
@ 2023-12-27 12:15 tompng (tomoya ishida) via ruby-core
  2023-12-28 14:56 ` [ruby-core:115963] " dentarg (Patrik Ragnarsson) via ruby-core
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tompng (tomoya ishida) via ruby-core @ 2023-12-27 12:15 UTC (permalink / raw)
  To: ruby-core; +Cc: tompng (tomoya ishida)

Issue #20098 has been reported by tompng (tomoya ishida).

----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:115963] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
  2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
@ 2023-12-28 14:56 ` dentarg (Patrik Ragnarsson) via ruby-core
  2023-12-28 19:44 ` [ruby-core:115968] " tompng (tomoya ishida) via ruby-core
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dentarg (Patrik Ragnarsson) via ruby-core @ 2023-12-28 14:56 UTC (permalink / raw)
  To: ruby-core; +Cc: dentarg (Patrik Ragnarsson)

Issue #20098 has been updated by dentarg (Patrik Ragnarsson).


Same as https://bugs.ruby-lang.org/issues/20083?

----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098#change-105922

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:115968] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
  2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
  2023-12-28 14:56 ` [ruby-core:115963] " dentarg (Patrik Ragnarsson) via ruby-core
@ 2023-12-28 19:44 ` tompng (tomoya ishida) via ruby-core
  2024-02-13  6:19 ` [ruby-core:116686] " weilandia (Nick Weiland) via ruby-core
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tompng (tomoya ishida) via ruby-core @ 2023-12-28 19:44 UTC (permalink / raw)
  To: ruby-core; +Cc: tompng (tomoya ishida)

Issue #20098 has been updated by tompng (tomoya ishida).


Not same. https://bugs.ruby-lang.org/issues/20083 is fixed in master branch. This issue is found in a branch that fixes 20083.

----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098#change-105927

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:116686] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
  2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
  2023-12-28 14:56 ` [ruby-core:115963] " dentarg (Patrik Ragnarsson) via ruby-core
  2023-12-28 19:44 ` [ruby-core:115968] " tompng (tomoya ishida) via ruby-core
@ 2024-02-13  6:19 ` weilandia (Nick Weiland) via ruby-core
  2024-03-20 23:53 ` [ruby-core:117273] " naruse (Yui NARUSE) via ruby-core
  2024-03-31  8:31 ` [ruby-core:117382] " nagachika (Tomoyuki Chikanaga) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: weilandia (Nick Weiland) via ruby-core @ 2024-02-13  6:19 UTC (permalink / raw)
  To: ruby-core; +Cc: weilandia (Nick Weiland)

Issue #20098 has been updated by weilandia (Nick Weiland).


Looks to be the same bug, but I cannot make it match with the backref.  Below example matches in 3.2.2 but not in 3.3.0
``` ruby
str = "------------abcdefg------------#3895912"
re = /()\1\b\w*[a-zA-Z-]*\d+[\w-]{3,}\w+\b/
re.match?(str)
```



----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098#change-106699

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:117273] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
  2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
                   ` (2 preceding siblings ...)
  2024-02-13  6:19 ` [ruby-core:116686] " weilandia (Nick Weiland) via ruby-core
@ 2024-03-20 23:53 ` naruse (Yui NARUSE) via ruby-core
  2024-03-31  8:31 ` [ruby-core:117382] " nagachika (Tomoyuki Chikanaga) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: naruse (Yui NARUSE) via ruby-core @ 2024-03-20 23:53 UTC (permalink / raw)
  To: ruby-core; +Cc: naruse (Yui NARUSE)

Issue #20098 has been updated by naruse (Yui NARUSE).

Backport changed from 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED, 3.3: REQUIRED to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED, 3.3: DONE

ruby_3_3 7ae8abc23961bf4fa143a7a2cc0bc38167d468ae merged revision(s) bb59696614083660241ef272f222628cbfa95844.

----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098#change-107398

* Author: tompng (tomoya ishida)
* Status: Closed
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED, 3.3: DONE
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:117382] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3
  2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
                   ` (3 preceding siblings ...)
  2024-03-20 23:53 ` [ruby-core:117273] " naruse (Yui NARUSE) via ruby-core
@ 2024-03-31  8:31 ` nagachika (Tomoyuki Chikanaga) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: nagachika (Tomoyuki Chikanaga) via ruby-core @ 2024-03-31  8:31 UTC (permalink / raw)
  To: ruby-core; +Cc: nagachika (Tomoyuki Chikanaga)

Issue #20098 has been updated by nagachika (Tomoyuki Chikanaga).


The changeset bb59696614083660241ef272f222628cbfa95844 cannot be merged into ruby_3_2 branch cleanly and hard to me to write a patch. @tompng Could you kindly create the patch for ruby_3_2 branch?

----------------------------------------
Bug #20098: Wrong regexp match in ruby 3.2 and 3.3
https://bugs.ruby-lang.org/issues/20098#change-107543

* Author: tompng (tomoya ishida)
* Status: Closed
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +MN [arm64-darwin22]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED, 3.3: DONE
----------------------------------------
These regexp all matches in ruby 3.1.4, but not in ruby 3.3.0.
~~~ruby
p /a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz' # matches in ruby 3.2.2
p /a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Adding backref (to disable optimization) makes them match.
~~~ruby
p /()\1a((.|.)|bc){,4}z/.match? 'abcbcbcbcz'
p /()\1a(b+?c*){4,5}z/.match? 'abbbccbbbccbcbcz'
p /()\1a(b+?(.|.)){2,3}z/.match? 'abbbcbbbcbbbcz'
p /()\1a(b*?(.|.)[bc]){2,5}z/.match? 'abcbbbcbcccbcz'
~~~

Found in this script https://gist.github.com/tompng/aa0706a181e9187bd79e8cec5a5f3c97




-- 
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-31  8:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-27 12:15 [ruby-core:115933] [Ruby master Bug#20098] Wrong regexp match in ruby 3.2 and 3.3 tompng (tomoya ishida) via ruby-core
2023-12-28 14:56 ` [ruby-core:115963] " dentarg (Patrik Ragnarsson) via ruby-core
2023-12-28 19:44 ` [ruby-core:115968] " tompng (tomoya ishida) via ruby-core
2024-02-13  6:19 ` [ruby-core:116686] " weilandia (Nick Weiland) via ruby-core
2024-03-20 23:53 ` [ruby-core:117273] " naruse (Yui NARUSE) via ruby-core
2024-03-31  8:31 ` [ruby-core:117382] " nagachika (Tomoyuki Chikanaga) via ruby-core

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 NNTP newsgroup(s).