[#105104] [Ruby master Bug#18141] Marshal load with proc yield strings before they are fully initialized — "byroot (Jean Boussier)" <noreply@...>

Issue #18141 has been reported by byroot (Jean Boussier).

10 messages 2021/09/01

[#105114] [Ruby master Feature#18143] Add a new method to change GC.stress only in the given block such as GC.with_stress(flag) {...} — "kou (Kouhei Sutou)" <noreply@...>

Issue #18143 has been reported by kou (Kouhei Sutou).

8 messages 2021/09/02

[#105180] [Ruby master Bug#18156] 3.0.2 configuration checks by default for C++ compiler instead of C? — "vo.x (Vit Ondruch)" <noreply@...>

Issue #18156 has been reported by vo.x (Vit Ondruch).

11 messages 2021/09/08

[#105191] [Ruby master Bug#18159] Integrate functionality of dead_end gem into Ruby — duerst <noreply@...>

Issue #18159 has been reported by duerst (Martin D=FCrst).

37 messages 2021/09/11

[#105269] [Ruby master Bug#18169] Local copies of gemified libraries are being released out of sync with their gems — "headius (Charles Nutter)" <noreply@...>

Issue #18169 has been reported by headius (Charles Nutter).

15 messages 2021/09/15

[#105276] [Ruby master Bug#18170] Exception#inspect should not include newlines — "mame (Yusuke Endoh)" <noreply@...>

Issue #18170 has been reported by mame (Yusuke Endoh).

29 messages 2021/09/16

[#105310] [Ruby master Misc#18174] DevelopersMeeting20211021Japan — "mame (Yusuke Endoh)" <noreply@...>

Issue #18174 has been reported by mame (Yusuke Endoh).

14 messages 2021/09/16

[#105313] [Ruby master Misc#18175] Propose Jean Boussier (@byroot) as a core committer — "tenderlovemaking (Aaron Patterson)" <noreply@...>

Issue #18175 has been reported by tenderlovemaking (Aaron Patterson).

11 messages 2021/09/16

[#105354] [Ruby master Feature#18181] Introduce Enumerable#min_with_value, max_with_value, and minmax_with_value — "kyanagi (Kouhei Yanagita)" <noreply@...>

Issue #18181 has been reported by kyanagi (Kouhei Yanagita).

16 messages 2021/09/20

[#105361] [Ruby master Feature#18183] make SecureRandom.choose public — "olleicua (Antha Auciello)" <noreply@...>

Issue #18183 has been reported by olleicua (Antha Auciello).

17 messages 2021/09/21

[#105377] [Ruby master Bug#18187] Float#clamp() returns ArgumentError (comparison of Float with 1 failed) — "SouravGoswami (Sourav Goswami)" <noreply@...>

SXNzdWUgIzE4MTg3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IFNvdXJhdkdvc3dhbWkgKFNvdXJhdiBH

7 messages 2021/09/22

[#105391] [Ruby master Bug#18189] `rb_cString` can be NULL during `Init_Object` — "ioquatix (Samuel Williams)" <noreply@...>

SXNzdWUgIzE4MTg5IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGlvcXVhdGl4IChTYW11ZWwgV2lsbGlh

9 messages 2021/09/23

[#105428] [Ruby master Bug#18194] No easy way to format exception messages per thread/fiber scheduler context. — "ioquatix (Samuel Williams)" <noreply@...>

SXNzdWUgIzE4MTk0IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGlvcXVhdGl4IChTYW11ZWwgV2lsbGlh

16 messages 2021/09/26

[#105450] [Ruby master Feature#18228] Add a `timeout` option to `IO.copy_stream` — "byroot (Jean Boussier)" <noreply@...>

SXNzdWUgIzE4MjI4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku

11 messages 2021/09/27

[#105452] [Ruby master Feature#18229] Proposal to merge YJIT — "maximecb (Maxime Chevalier-Boisvert)" <noreply@...>

SXNzdWUgIzE4MjI5IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IG1heGltZWNiIChNYXhpbWUgQ2hldmFs

21 messages 2021/09/27

[#105500] [Ruby master Feature#18231] `RubyVM.keep_script_lines` — "ko1 (Koichi Sasada)" <noreply@...>

SXNzdWUgIzE4MjMxIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtvMSAoS29pY2hpIFNhc2FkYSkuCgot

19 messages 2021/09/30

[#105504] [Ruby master Bug#18232] Ractor.make_shareable is broken in code loaded with RubyVM::InstructionSequence.load_from_binary — "byroot (Jean Boussier)" <noreply@...>

SXNzdWUgIzE4MjMyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku

7 messages 2021/09/30

[ruby-core:105114] [Ruby master Feature#18143] Add a new method to change GC.stress only in the given block such as GC.with_stress(flag) {...}

From: "kou (Kouhei Sutou)" <noreply@...>
Date: 2021-09-02 02:45:52 UTC
List: ruby-core #105114
Issue #18143 has been reported by kou (Kouhei Sutou).

----------------------------------------
Feature #18143: Add a new method to change GC.stress only in the given block such as GC.with_stress(flag) {...}
https://bugs.ruby-lang.org/issues/18143

* Author: kou (Kouhei Sutou)
* Status: Open
* Priority: Normal
----------------------------------------
`GC.stress = true` is useful for detecting GC related crashes. We can use it for debugging GC related problems and testing the problem is solved.

Generally, we need to enable stress mode before the target code block and disable stress mode after the target code block:

```ruby
GC.stress = true
# ... something buggy codes ...
GC.stress = false
```

Or we just enable stress mode before the target code block when the target code block causes a crash:

```ruby
GC.stress = true
# ... something crash codes ...
```

In test code, we must disable stress mode because stress mode slows down test execution:

```ruby
def test_gc
  GC.stress = true
  # ... GC related code ...
ensure
  GC.stress = false
end
```

We have an utility method in CRuby's test utility: `EnvUtil.#under_gc_stress`:

https://github.com/ruby/ruby/blob/ab63f6d8543903f177c46634f38e5428655f003b/tool/lib/envutil.rb#L236-L242

```ruby
  def under_gc_stress(stress = true)
    stress, GC.stress = GC.stress, stress
    yield
  ensure
    GC.stress = stress
  end
  module_function :under_gc_stress
```

This feature is useful not only CRuby's test but also other libraries test and debugging a program that has a GC related problem.

How about adding a new singleton method that changes stress mode only in the given block? If we have the method, we don't need to implement a small utility method multiple times for the feature.

API candidates:

`GC.with_stress(flag) {...}`:

```ruby
module GC
  def self.with_stress(flag)
    flag_old = stress
    self.stress = flag
    yield
  ensure
    self.stress = flag_old
  end
end
```

`GC.under_stress {...}`:

```ruby
module GC
  def self.under_stress
    flag_old = stress
    self.stress = true
    yield
  ensure
    self.stress = flag_old
  end
end
```

`GC.stress(flag = true) {...}`:

```ruby
module GC
  def stress flag = true
    if block_given?
      flag_old = Primitive.gc_stress_get
      begin
        GC.stress = flag
      ensure
        GC.stress = flag_old
      end
    else
      Primitive.gc_stress_get
    end
  end
end
```

Note:

  * Disadvantage is, `GC.stress` is a getter method and `GC.stress do end` is setter method. It can be confusing.
  * @nobu also pointed out that the block is just ignored on the older Ruby versions.

Source of implementation and some discussions: https://github.com/ruby/ruby/pull/4793

Background:

I'm maintaining some default gems. They have copy of `EnvUtil` but I don't want to have it for maintainability. If Ruby provides this feature by default, we can use it instead of copying `EnvUtil`. I know that I need to implement/copy the feature in each default gem until Ruby 3.0 reaches EOL. But we don't have the feature now, I need to copy `EnvUtil` forever.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next