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

Backport changed from 2.5: REQUIRED, 2.6: REQUIRED to 2.5: REQUIRED, 2.6: DONE

ruby_2_6 r67835 merged revision(s) ff41663403d3eb76d95f465cb94e14d2faaa04d1.

----------------------------------------
Bug #16354: Memory corruption in Enumerable#reverse_each
https://bugs.ruby-lang.org/issues/16354#change-83138

* Author: ktsj (Kazuki Tsujimoto)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: REQUIRED, 2.6: DONE
----------------------------------------
Enumerable#reverse_eachのブロック呼び出し中に、対象のEnumerableをto_aしたものを捕まえてサイズを変更するとSEGVすることがあります。

```
$ ruby -e '(0...1000).reverse_each {|i| i.inspect; ObjectSpace.each_object(Array) {|a| a.clear if a.length == 1000 }}'
-e:1: [BUG] Segmentation fault at 0x0000000000005f19
```




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