ruby/internal
Peter Zhu 62c2082f1f [Bug #19469] Fix crash when resizing generic iv list
The following script can sometimes trigger a crash:

```ruby
GC.stress = true

class Array
  def foo(bool)
    if bool
      @a = 1
      @b = 2
      @c = 1
    else
      @c = 1
    end
  end
end

obj = []
obj.foo(true)

obj2 = []
obj2.foo(false)

obj3 = []
obj3.foo(true)
```

This is because vm_setivar_default calls rb_ensure_generic_iv_list_size
to resize the iv list. However, the call to gen_ivtbl_resize reallocs
the iv list, and then inserts into the generic iv table. If the
st_insert triggers a GC then the old iv list will be read during
marking, causing a use-after-free bug.

Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
2023-03-03 16:12:03 -05:00
..
2022-12-17 14:51:49 -08:00
2022-12-02 01:31:27 +09:00
2022-07-03 09:42:44 -07:00
2023-02-09 10:32:29 -05:00
2023-01-18 08:49:32 -05:00
2023-01-18 08:49:32 -05:00
2022-11-02 11:03:21 -04:00
2023-01-18 08:49:32 -05:00
2022-10-21 14:56:48 -07:00