Project

General

Profile

Actions

Bug #12923

closed

Accessing singleton_class of fstring cause assertion failure

Bug #12923: Accessing singleton_class of fstring cause assertion failure

Added by naruse (Yui NARUSE) almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Target version:
-
[ruby-dev:49867]

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);"で落ちる

しかし、どう直しましょうかね。


Related issues 2 (0 open2 closed)

Related to Ruby - Bug #11386: taint flag about rb_fstring()ClosedActions
Related to Ruby - Bug #12930: instance_eval, instance_exec raises TypeError on a frozen StringClosedmatz (Yukihiro Matsumoto)Actions

Updated by naruse (Yui NARUSE) almost 9 years ago Actions #1

  • Related to Bug #11386: taint flag about rb_fstring() added

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago Actions #2 [ruby-dev:49873]

RBASIC_CLASSrb_obj_classにしてassertionを緩めましょうか。

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago Actions #3

  • 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 9 years ago Actions #4 [ruby-dev:49874]

  • 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 9 years ago Actions #5

  • 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 9 years ago Actions #6

  • Related to Bug #12930: instance_eval, instance_exec raises TypeError on a frozen String added

Updated by nobu (Nobuyoshi Nakada) over 8 years ago Actions #7 [ruby-dev:49987]

  • 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 8 years ago Actions #8

  • 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 8 years ago Actions #9

  • 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 8 years ago Actions #10 [ruby-dev:50049]

  • 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 8 years ago Actions #11

  • Backport changed from 2.2: DONTNEED, 2.3: DONE, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONE, 2.4: DONTNEED
Actions

Also available in: PDF Atom