Project

General

Profile

Actions

Bug #12923

closed

Accessing singleton_class of fstring cause assertion failure

Added by naruse (Yui NARUSE) about 8 years ago. Updated over 7 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 master - Bug #11386: taint flag about rb_fstring()ClosedActions
Related to Ruby master - Bug #12930: instance_eval, instance_exec raises TypeError on a frozen StringClosedmatz (Yukihiro Matsumoto)Actions
Actions #1

Updated by naruse (Yui NARUSE) about 8 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

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

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 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) about 8 years ago

  • Status changed from Closed to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

ひとまずSEGVはしないようにfstringはsingleton classを作れないようにします。
笹田さんと話したのですが、frozen object全般でsingleton classの追加を禁止したほうがよさそうという結論になりました。
まつもとさんはどうでしょうか。

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 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]
Actions #6

Updated by matsuda (Akira Matsuda) about 8 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED
Actions #8

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
Actions #9

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.

Actions #11

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0