ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:118680] [Ruby master Bug#20650] Memory leak in Regexp capture group when timeout
@ 2024-07-24 19:19 peterzhu2118 (Peter Zhu) via ruby-core
  2024-07-25 13:54 ` [ruby-core:118684] " peterzhu2118 (Peter Zhu) via ruby-core
  0 siblings, 1 reply; 2+ messages in thread
From: peterzhu2118 (Peter Zhu) via ruby-core @ 2024-07-24 19:19 UTC (permalink / raw)
  To: ruby-core; +Cc: peterzhu2118 (Peter Zhu)

Issue #20650 has been reported by peterzhu2118 (Peter Zhu).

----------------------------------------
Bug #20650: Memory leak in Regexp capture group when timeout
https://bugs.ruby-lang.org/issues/20650

* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/11238

The capture group allocates memory that is leaked when it times out.

For example:

```ruby
re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
str = "a" * 1000000 + "x"

10.times do
  100.times do
    re =~ str
  rescue Regexp::TimeoutError
  end

  puts `ps -o rss= -p #{$$}`
end
```

Before:

```
34688
56416
78288
100368
120784
140704
161904
183568
204320
224800
```

After:

```
16288
16288
16880
16896
16912
16928
16944
17184
17184
17200
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:118684] [Ruby master Bug#20650] Memory leak in Regexp capture group when timeout
  2024-07-24 19:19 [ruby-core:118680] [Ruby master Bug#20650] Memory leak in Regexp capture group when timeout peterzhu2118 (Peter Zhu) via ruby-core
@ 2024-07-25 13:54 ` peterzhu2118 (Peter Zhu) via ruby-core
  0 siblings, 0 replies; 2+ messages in thread
From: peterzhu2118 (Peter Zhu) via ruby-core @ 2024-07-25 13:54 UTC (permalink / raw)
  To: ruby-core; +Cc: peterzhu2118 (Peter Zhu)

Issue #20650 has been updated by peterzhu2118 (Peter Zhu).

Backport changed from 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: UNKNOWN, 3.2: WONTFIX, 3.3: REQUIRED

I opened a Ruby 3.3 backport here: https://github.com/ruby/ruby/pull/11244

----------------------------------------
Bug #20650: Memory leak in Regexp capture group when timeout
https://bugs.ruby-lang.org/issues/20650#change-109221

* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Backport: 3.1: UNKNOWN, 3.2: WONTFIX, 3.3: REQUIRED
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/11238

The capture group allocates memory that is leaked when it times out.

For example:

```ruby
re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
str = "a" * 1000000 + "x"

10.times do
  100.times do
    re =~ str
  rescue Regexp::TimeoutError
  end

  puts `ps -o rss= -p #{$$}`
end
```

Before:

```
34688
56416
78288
100368
120784
140704
161904
183568
204320
224800
```

After:

```
16288
16288
16880
16896
16912
16928
16944
17184
17184
17200
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2024-07-25 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 19:19 [ruby-core:118680] [Ruby master Bug#20650] Memory leak in Regexp capture group when timeout peterzhu2118 (Peter Zhu) via ruby-core
2024-07-25 13:54 ` [ruby-core:118684] " peterzhu2118 (Peter Zhu) 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).