Bug #12923
closedAccessing singleton_class of fstring cause assertion failure
Description
以下のワンライナーが「Assertion Failed: string.c:343:register_fstring:RBASIC_CLASS(ret) == rb_cString」します。
./miniruby -e'#encoding:us-ascii' -e'ObjectSpace.each_object{|o| o.singleton_class if o.is_a?(String)}; "hoge".intern'
クラッシュログは自分で走らせてもらうとして、何が起きているかというと、
(1) 文字列リテラルをはじめとして、何らかのかたちでシンボルを作らずにrb_fstringからfrozenなStringを作る
(2) その文字列に対してsingleton_classを呼ぶ。するとそのRVALUE->klassにsingleton_classが代入される
(3) 同じ内容の文字列でString#internする(1.でシンボルを作っているとlookup_str_sym()にひっかかる)
(4) register_fstringの"assert(RBASIC_CLASS(ret) == rb_cString);"で落ちる
しかし、どう直しましょうかね。
Updated by naruse (Yui NARUSE) almost 8 years ago
- Related to Bug #11386: taint flag about rb_fstring() added
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
RBASIC_CLASS
をrb_obj_class
にしてassertionを緩めましょうか。
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
- Status changed from Open to Closed
Applied in changeset r56747.
class.c: no fstring singleton class
- class.c (singleton_class_of): prohibit fstrings from creating
singleton classes.
temporary measure for [ruby-dev:49867] [Bug #12923]
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
- Status changed from Closed to Assigned
- Assignee set to matz (Yukihiro Matsumoto)
ひとまずSEGVはしないようにfstringはsingleton classを作れないようにします。
笹田さんと話したのですが、frozen object全般でsingleton classの追加を禁止したほうがよさそうという結論になりました。
まつもとさんはどうでしょうか。
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
- Status changed from Assigned to Closed
Applied in changeset r56754.
test_fstring.rb: fix exception
- test/-ext-/string/test_fstring.rb (test_singleton_class): fix
expected exception class. [ruby-dev:49867] [Bug #12923]
Updated by matsuda (Akira Matsuda) almost 8 years ago
- Related to Bug #12930: instance_eval, instance_exec raises TypeError on a frozen String added
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED
Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago
- Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED to 2.2: DONTNEED, 2.3: WONTFIX, 2.4: DONTNEED
Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago
- Backport changed from 2.2: DONTNEED, 2.3: WONTFIX, 2.4: DONTNEED to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago
- Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONE, 2.4: REQUIRED
ruby_2_3 r58157 merged revision(s) 56747,56754,56777.
Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago
- Backport changed from 2.2: DONTNEED, 2.3: DONE, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONE, 2.4: DONTNEED