Issue #10877 has been updated by Nobuyoshi Nakada.

File bug-10877.log added
Description updated
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Shorter code:

~~~ruby
"a".sub("a", "")
$~["foo"]
~~~

----------------------------------------
Bug #10877: String#sub causes segfault
https://bugs.ruby-lang.org/issues/10877#change-51577

* Author: Wei-Hang Jian
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2.0
* Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED
----------------------------------------
~~~ruby
str = 'abc'
reg = /(?<foo>a)bc/
str =~ reg
$~['foo'].sub 'a', ''
$~['foo']
~~~

~~~
tmp.rb:5: [BUG] Segmentation fault at 0x00000000000020

Abort trap: 6
~~~

---Files--------------------------------
bug-10877.log (3.92 KB)


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