key first.
Garbage keys can be swept by lazy sweeping invoked by creating new
fstring. So that simply do:
(1) delete garbage key and return `fstr_update_callback' immediately
(2) try again `fstr_update_callback()' to create a new fstr.
This bug can be cause memory corruption, reported by
http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20140821T220302Z.fail.html.gz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_setup_fake_str): setup fake string from C pointer,
length, and encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RBASIC_SET_CLASS() because it insert write barriers to fake
(non-RVALUE) structure.
It can cause unexpected behaviour.
Ruby 2.1 also have a same problem (setup_fake_str() in parse.y).
* symbol.c (setup_fake_str): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_to_symbol): new function to convert an object to a
symbol.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_count): move code for the first argument
outside loop for the rest, as it is executed only once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
exposing IDs from collectable symbols.
[Bug #10014]
Now, rb_check_id() returns 0 if corresponding symbol is
pinned dynamic symbol.
There is remaining intern_cstr_without_pindown(), it can return
IDs from collectable symbols. We must be careful to use it
(only used in parse.y). I think it should be removed if
it does not have impact for performance.
* parse.y:
add:
* STATIC_SYM2ID()
* STATIC_ID2SYM()
rename:
* rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
remove:
* rb_check_id_without_pindown()
* rb_sym2id_without_pindown()
add:
* rb_check_symbol()
* rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (fstr_update_callback): should not access garbage
object contents, copy from the argument instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
any more.
Make new frozen string and replace with garbage frozen string.
* common.mk: use gc.h from string.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_fstring_new): make US-ASCII string. another
function may be used for non-ASCII strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (sym_succ, sym_cmp, sym_casecmp, sym_match, sym_aref):
not need to make copy of interned strings, use directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_resize): should consider the capacity instead
of the old length, as pointed out by nagachika.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_freeze): shrink the buffer before freezing, as
pointed out by Eric Wong at [ruby-core:63119].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_resize): shrink the buffer even if new length
is same but it is enough smaller than the capacity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_slice_bang): [DOC] update return value against
a fixnum, which has changed because of M17N. [fix GH-631]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_substr): need to reset code range for shared
string too, not only copied string.
[ruby-core:62842] [Bug #9882]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_pat_search): advance by byte offset but not by char
offset. [ruby-core:62669] [Bug #9849]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
ASCII character.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_update): rename rb_str_splice as exported name
rb_str_update, and make the former an alias macro of the latter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (SHARABLE_SUBSTRING_P): predicate if substring can be
shared with the original string. true if just at the end of the
original string, for the time being. all substring will be able to
be shared in the future.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (str_buf_cat): revert r45622. broken data can be added
later.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (str_buf_cat): revert r45621. this function does not
scan appended data.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_cat_cstr): check the argument as other `_cstr`
functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_cat, rb_str_cat2): make aliases of
rb_str_buf_cat and rb_str_buf_cat2 respectively.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_cat, rb_str_cat2): reduce duplicated code, they
are same as rb_str_buf_cat and rb_str_buf_cat2 respectively now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_enc_cr_str_buf_cat): keep code range of the source
string even if code range of the destination string is unknown.
no reason to the former is affected by the latter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
caller's self which is useless, so that it can get collected.
[Fixes GH-592]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (str_buf_cat): remove unnecessary terminator space,
since the capacity does not include its length but RESIZE_CAPA()
considers it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (str_buf_cat): should round up the capacity by 4KiB,
but not number of rooms. [ruby-core:61886] [Bug #9709]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e