Project

General

Profile

Bug #12923

Accessing singleton_class of fstring cause assertion failure

Added by naruse (Yui NARUSE) about 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
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

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 StringClosedActions

Associated revisions

Revision ee160e68
Added by nobu (Nobuyoshi Nakada) about 3 years ago

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56747
Added by nobu (Nobuyoshi Nakada) about 3 years ago

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]

Revision 56747
Added by nobu (Nobuyoshi Nakada) about 3 years ago

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]

Revision 56747
Added by nobu (Nobuyoshi Nakada) about 3 years ago

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]

Revision 56747
Added by nobu (Nobuyoshi Nakada) about 3 years ago

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]

Revision c62ab010
Added by nobu (Nobuyoshi Nakada) about 3 years ago

test_fstring.rb: fix exception

  • test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56754
Added by nobu (Nobuyoshi Nakada) about 3 years ago

test_fstring.rb: fix exception

  • test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923]

Revision 56754
Added by nobu (Nobuyoshi Nakada) about 3 years ago

test_fstring.rb: fix exception

  • test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923]

Revision 56754
Added by nobu (Nobuyoshi Nakada) about 3 years ago

test_fstring.rb: fix exception

  • test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923]

Revision 56754
Added by nobu (Nobuyoshi Nakada) about 3 years ago

test_fstring.rb: fix exception

  • test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923]

Revision 56777
Added by nobu (Nobuyoshi Nakada) about 3 years ago

vm_eval.c: fstring instance_eval

  • vm_eval.c (singleton_class_for_eval): enable fstring singleton class for instance_eval. [ruby-core:78116] [Bug #12930]

Revision 018eeaf2
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 56747,56754,56777: [Backport #12923] [Backport #12930] [Backport #13238]

    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]
    test_fstring.rb: fix exception

    * test/-ext-/string/test_fstring.rb (test_singleton_class): fix
      expected exception class.  [ruby-dev:49867] [Bug #12923]
    vm_eval.c: fstring instance_eval

    * vm_eval.c (singleton_class_for_eval): enable fstring singleton
      class for instance_eval.  [ruby-core:78116] [Bug #12930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58157
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 56747,56754,56777: [Backport #12923] [Backport #12930] [Backport #13238]

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]
test_fstring.rb: fix exception

* test/-ext-/string/test_fstring.rb (test_singleton_class): fix
  expected exception class.  [ruby-dev:49867] [Bug #12923]
vm_eval.c: fstring instance_eval

* vm_eval.c (singleton_class_for_eval): enable fstring singleton
  class for instance_eval.  [ruby-core:78116] [Bug #12930]

History

#1

Updated by naruse (Yui NARUSE) about 3 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

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

#3

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

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

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

#5

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

Updated by matsuda (Akira Matsuda) about 3 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

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

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED to 2.2: DONTNEED, 2.3: WONTFIX, 2.4: DONTNEED
#9

Updated by nagachika (Tomoyuki Chikanaga) over 2 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 2 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.

#11

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

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

Also available in: Atom PDF