mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Get rid of indirect sharing
* string.c (str_duplicate): share the root shared string if the
original string is already sharing, so that all shared strings
refer the root shared string directly. indirect sharing can
cause a dangling pointer.
[Bug #15792]
str_duplicate: Don't share with a frozen shared string
This is a follow up for 3f9562015e.
Before this commit, it was possible to create a shared string which
shares with another shared string by passing a frozen shared string
to `str_duplicate`.
Such string looks like:
```
-------- -----------------
| root | ------ owns -----> | root's buffer |
-------- -----------------
^ ^ ^
----------- | |
| shared1 | ------ references ----- |
----------- |
^ |
----------- |
| shared2 | ------ references ---------
-----------
```
This is bad news because `rb_fstring(shared2)` can make `shared1`
independent, which severs the reference from `shared1` to `root`:
```c
/* from fstr_update_callback() */
str = str_new_frozen(rb_cString, shared2); /* can return shared1 */
if (STR_SHARED_P(str)) { /* shared1 is also a shared string */
str_make_independent(str); /* no frozen check */
}
```
If `shared1` was the only reference to `root`, then `root` can be
reclaimed by the GC, leaving `shared2` in a corrupted state:
```
----------- --------------------
| shared1 | -------- owns --------> | shared1's buffer |
----------- --------------------
^
|
----------- -------------------------
| shared2 | ------ references ----> | root's buffer (freed) |
----------- -------------------------
```
Here is a reproduction script for the situation this commit fixes.
```ruby
a = ('a' * 24).strip.freeze.strip
-a
p a
4.times { GC.start }
p a
```
- string.c (str_duplicate): always share with the root string when
the original is a shared string.
- test_rb_str_dup.rb: specifically test `rb_str_dup` to make
sure it does not try to share with a shared string.
[Bug #15792]
Closes: https://github.com/ruby/ruby/pull/2159
Update dependencies
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
198 lines
6.7 KiB
Text
198 lines
6.7 KiB
Text
# AUTOGENERATED DEPENDENCIES START
|
|
capacity.o: $(RUBY_EXTCONF_H)
|
|
capacity.o: $(arch_hdrdir)/ruby/config.h
|
|
capacity.o: $(hdrdir)/ruby/backward.h
|
|
capacity.o: $(hdrdir)/ruby/defines.h
|
|
capacity.o: $(hdrdir)/ruby/encoding.h
|
|
capacity.o: $(hdrdir)/ruby/intern.h
|
|
capacity.o: $(hdrdir)/ruby/io.h
|
|
capacity.o: $(hdrdir)/ruby/missing.h
|
|
capacity.o: $(hdrdir)/ruby/onigmo.h
|
|
capacity.o: $(hdrdir)/ruby/oniguruma.h
|
|
capacity.o: $(hdrdir)/ruby/ruby.h
|
|
capacity.o: $(hdrdir)/ruby/st.h
|
|
capacity.o: $(hdrdir)/ruby/subst.h
|
|
capacity.o: $(top_srcdir)/include/ruby.h
|
|
capacity.o: $(top_srcdir)/internal.h
|
|
capacity.o: capacity.c
|
|
coderange.o: $(RUBY_EXTCONF_H)
|
|
coderange.o: $(arch_hdrdir)/ruby/config.h
|
|
coderange.o: $(hdrdir)/ruby/backward.h
|
|
coderange.o: $(hdrdir)/ruby/defines.h
|
|
coderange.o: $(hdrdir)/ruby/encoding.h
|
|
coderange.o: $(hdrdir)/ruby/intern.h
|
|
coderange.o: $(hdrdir)/ruby/missing.h
|
|
coderange.o: $(hdrdir)/ruby/onigmo.h
|
|
coderange.o: $(hdrdir)/ruby/oniguruma.h
|
|
coderange.o: $(hdrdir)/ruby/ruby.h
|
|
coderange.o: $(hdrdir)/ruby/st.h
|
|
coderange.o: $(hdrdir)/ruby/subst.h
|
|
coderange.o: coderange.c
|
|
cstr.o: $(RUBY_EXTCONF_H)
|
|
cstr.o: $(arch_hdrdir)/ruby/config.h
|
|
cstr.o: $(hdrdir)/ruby/backward.h
|
|
cstr.o: $(hdrdir)/ruby/defines.h
|
|
cstr.o: $(hdrdir)/ruby/encoding.h
|
|
cstr.o: $(hdrdir)/ruby/intern.h
|
|
cstr.o: $(hdrdir)/ruby/io.h
|
|
cstr.o: $(hdrdir)/ruby/missing.h
|
|
cstr.o: $(hdrdir)/ruby/onigmo.h
|
|
cstr.o: $(hdrdir)/ruby/oniguruma.h
|
|
cstr.o: $(hdrdir)/ruby/ruby.h
|
|
cstr.o: $(hdrdir)/ruby/st.h
|
|
cstr.o: $(hdrdir)/ruby/subst.h
|
|
cstr.o: $(top_srcdir)/include/ruby.h
|
|
cstr.o: $(top_srcdir)/internal.h
|
|
cstr.o: cstr.c
|
|
ellipsize.o: $(RUBY_EXTCONF_H)
|
|
ellipsize.o: $(arch_hdrdir)/ruby/config.h
|
|
ellipsize.o: $(hdrdir)/ruby/backward.h
|
|
ellipsize.o: $(hdrdir)/ruby/defines.h
|
|
ellipsize.o: $(hdrdir)/ruby/intern.h
|
|
ellipsize.o: $(hdrdir)/ruby/missing.h
|
|
ellipsize.o: $(hdrdir)/ruby/ruby.h
|
|
ellipsize.o: $(hdrdir)/ruby/st.h
|
|
ellipsize.o: $(hdrdir)/ruby/subst.h
|
|
ellipsize.o: $(top_srcdir)/include/ruby.h
|
|
ellipsize.o: ellipsize.c
|
|
enc_associate.o: $(RUBY_EXTCONF_H)
|
|
enc_associate.o: $(arch_hdrdir)/ruby/config.h
|
|
enc_associate.o: $(hdrdir)/ruby/backward.h
|
|
enc_associate.o: $(hdrdir)/ruby/defines.h
|
|
enc_associate.o: $(hdrdir)/ruby/encoding.h
|
|
enc_associate.o: $(hdrdir)/ruby/intern.h
|
|
enc_associate.o: $(hdrdir)/ruby/missing.h
|
|
enc_associate.o: $(hdrdir)/ruby/onigmo.h
|
|
enc_associate.o: $(hdrdir)/ruby/oniguruma.h
|
|
enc_associate.o: $(hdrdir)/ruby/ruby.h
|
|
enc_associate.o: $(hdrdir)/ruby/st.h
|
|
enc_associate.o: $(hdrdir)/ruby/subst.h
|
|
enc_associate.o: $(top_srcdir)/include/ruby.h
|
|
enc_associate.o: enc_associate.c
|
|
enc_str_buf_cat.o: $(RUBY_EXTCONF_H)
|
|
enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/backward.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/intern.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/missing.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/onigmo.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/oniguruma.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/ruby.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/st.h
|
|
enc_str_buf_cat.o: $(hdrdir)/ruby/subst.h
|
|
enc_str_buf_cat.o: enc_str_buf_cat.c
|
|
fstring.o: $(RUBY_EXTCONF_H)
|
|
fstring.o: $(arch_hdrdir)/ruby/config.h
|
|
fstring.o: $(hdrdir)/ruby/backward.h
|
|
fstring.o: $(hdrdir)/ruby/defines.h
|
|
fstring.o: $(hdrdir)/ruby/intern.h
|
|
fstring.o: $(hdrdir)/ruby/missing.h
|
|
fstring.o: $(hdrdir)/ruby/ruby.h
|
|
fstring.o: $(hdrdir)/ruby/st.h
|
|
fstring.o: $(hdrdir)/ruby/subst.h
|
|
fstring.o: $(top_srcdir)/include/ruby.h
|
|
fstring.o: fstring.c
|
|
init.o: $(RUBY_EXTCONF_H)
|
|
init.o: $(arch_hdrdir)/ruby/config.h
|
|
init.o: $(hdrdir)/ruby/backward.h
|
|
init.o: $(hdrdir)/ruby/defines.h
|
|
init.o: $(hdrdir)/ruby/intern.h
|
|
init.o: $(hdrdir)/ruby/missing.h
|
|
init.o: $(hdrdir)/ruby/ruby.h
|
|
init.o: $(hdrdir)/ruby/st.h
|
|
init.o: $(hdrdir)/ruby/subst.h
|
|
init.o: $(top_srcdir)/include/ruby.h
|
|
init.o: init.c
|
|
modify.o: $(RUBY_EXTCONF_H)
|
|
modify.o: $(arch_hdrdir)/ruby/config.h
|
|
modify.o: $(hdrdir)/ruby/backward.h
|
|
modify.o: $(hdrdir)/ruby/defines.h
|
|
modify.o: $(hdrdir)/ruby/intern.h
|
|
modify.o: $(hdrdir)/ruby/missing.h
|
|
modify.o: $(hdrdir)/ruby/ruby.h
|
|
modify.o: $(hdrdir)/ruby/st.h
|
|
modify.o: $(hdrdir)/ruby/subst.h
|
|
modify.o: $(top_srcdir)/include/ruby.h
|
|
modify.o: modify.c
|
|
new.o: $(RUBY_EXTCONF_H)
|
|
new.o: $(arch_hdrdir)/ruby/config.h
|
|
new.o: $(hdrdir)/ruby/backward.h
|
|
new.o: $(hdrdir)/ruby/defines.h
|
|
new.o: $(hdrdir)/ruby/encoding.h
|
|
new.o: $(hdrdir)/ruby/intern.h
|
|
new.o: $(hdrdir)/ruby/io.h
|
|
new.o: $(hdrdir)/ruby/missing.h
|
|
new.o: $(hdrdir)/ruby/onigmo.h
|
|
new.o: $(hdrdir)/ruby/oniguruma.h
|
|
new.o: $(hdrdir)/ruby/ruby.h
|
|
new.o: $(hdrdir)/ruby/st.h
|
|
new.o: $(hdrdir)/ruby/subst.h
|
|
new.o: $(top_srcdir)/include/ruby.h
|
|
new.o: $(top_srcdir)/internal.h
|
|
new.o: new.c
|
|
nofree.o: $(RUBY_EXTCONF_H)
|
|
nofree.o: $(arch_hdrdir)/ruby/config.h
|
|
nofree.o: $(hdrdir)/ruby/backward.h
|
|
nofree.o: $(hdrdir)/ruby/defines.h
|
|
nofree.o: $(hdrdir)/ruby/intern.h
|
|
nofree.o: $(hdrdir)/ruby/missing.h
|
|
nofree.o: $(hdrdir)/ruby/ruby.h
|
|
nofree.o: $(hdrdir)/ruby/st.h
|
|
nofree.o: $(hdrdir)/ruby/subst.h
|
|
nofree.o: $(top_srcdir)/include/ruby.h
|
|
nofree.o: nofree.c
|
|
normalize.o: $(RUBY_EXTCONF_H)
|
|
normalize.o: $(arch_hdrdir)/ruby/config.h
|
|
normalize.o: $(hdrdir)/ruby/backward.h
|
|
normalize.o: $(hdrdir)/ruby/defines.h
|
|
normalize.o: $(hdrdir)/ruby/encoding.h
|
|
normalize.o: $(hdrdir)/ruby/intern.h
|
|
normalize.o: $(hdrdir)/ruby/io.h
|
|
normalize.o: $(hdrdir)/ruby/missing.h
|
|
normalize.o: $(hdrdir)/ruby/onigmo.h
|
|
normalize.o: $(hdrdir)/ruby/oniguruma.h
|
|
normalize.o: $(hdrdir)/ruby/ruby.h
|
|
normalize.o: $(hdrdir)/ruby/st.h
|
|
normalize.o: $(hdrdir)/ruby/subst.h
|
|
normalize.o: $(top_srcdir)/include/ruby.h
|
|
normalize.o: $(top_srcdir)/internal.h
|
|
normalize.o: normalize.c
|
|
qsort.o: $(RUBY_EXTCONF_H)
|
|
qsort.o: $(arch_hdrdir)/ruby/config.h
|
|
qsort.o: $(hdrdir)/ruby/backward.h
|
|
qsort.o: $(hdrdir)/ruby/defines.h
|
|
qsort.o: $(hdrdir)/ruby/encoding.h
|
|
qsort.o: $(hdrdir)/ruby/intern.h
|
|
qsort.o: $(hdrdir)/ruby/missing.h
|
|
qsort.o: $(hdrdir)/ruby/onigmo.h
|
|
qsort.o: $(hdrdir)/ruby/oniguruma.h
|
|
qsort.o: $(hdrdir)/ruby/ruby.h
|
|
qsort.o: $(hdrdir)/ruby/st.h
|
|
qsort.o: $(hdrdir)/ruby/subst.h
|
|
qsort.o: $(hdrdir)/ruby/util.h
|
|
qsort.o: $(top_srcdir)/include/ruby.h
|
|
qsort.o: qsort.c
|
|
rb_str_dup.o: $(RUBY_EXTCONF_H)
|
|
rb_str_dup.o: $(arch_hdrdir)/ruby/config.h
|
|
rb_str_dup.o: $(hdrdir)/ruby.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/backward.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/defines.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/intern.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/missing.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/ruby.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/st.h
|
|
rb_str_dup.o: $(hdrdir)/ruby/subst.h
|
|
rb_str_dup.o: rb_str_dup.c
|
|
set_len.o: $(RUBY_EXTCONF_H)
|
|
set_len.o: $(arch_hdrdir)/ruby/config.h
|
|
set_len.o: $(hdrdir)/ruby/backward.h
|
|
set_len.o: $(hdrdir)/ruby/defines.h
|
|
set_len.o: $(hdrdir)/ruby/intern.h
|
|
set_len.o: $(hdrdir)/ruby/missing.h
|
|
set_len.o: $(hdrdir)/ruby/ruby.h
|
|
set_len.o: $(hdrdir)/ruby/st.h
|
|
set_len.o: $(hdrdir)/ruby/subst.h
|
|
set_len.o: $(top_srcdir)/include/ruby.h
|
|
set_len.o: set_len.c
|
|
# AUTOGENERATED DEPENDENCIES END
|