From: nobu@... Date: 2017-02-21T15:35:08+00:00 Subject: [ruby-dev:49987] [Ruby trunk Bug#12923] Accessing singleton_class of fstring cause assertion failure Issue #12923 has been updated by Nobuyoshi Nakada. Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED ---------------------------------------- Bug #12923: Accessing singleton_class of fstring cause assertion failure https://bugs.ruby-lang.org/issues/12923#change-63063 * Author: Yui NARUSE * Status: Closed * Priority: Normal * Assignee: Yukihiro Matsumoto * Target version: * ruby -v: * Backport: 2.2: DONTNEED, 2.3: REQUIRED, 2.4: DONTNEED ---------------------------------------- 以下のワンライナーが「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);"で落ちる しかし、どう直しましょうかね。 -- https://bugs.ruby-lang.org/