ruby-changes:3139
From: ko1@a...
Date: 25 Dec 2007 04:26:00 +0900
Subject: [ruby-changes:3139] akr - Ruby:r14631 (trunk): * parse.y (rb_id2str): fill klass of returned string as rb_cString.
akr 2007-12-25 04:25:45 +0900 (Tue, 25 Dec 2007) New Revision: 14631 Modified files: trunk/ChangeLog trunk/parse.y Log: * parse.y (rb_id2str): fill klass of returned string as rb_cString. some strings are allocated before rb_cString is created. This prevents a "called on terminated object" error by ObjectSpace.each_object(Module) {|m| p m.name }. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=14631&r2=14630 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14631&r2=14630 Index: ChangeLog =================================================================== --- ChangeLog (revision 14630) +++ ChangeLog (revision 14631) @@ -1,3 +1,10 @@ +Tue Dec 25 04:23:32 2007 Tanaka Akira <akr@f...> + + * parse.y (rb_id2str): fill klass of returned string as rb_cString. + some strings are allocated before rb_cString is created. + This prevents a "called on terminated object" error by + ObjectSpace.each_object(Module) {|m| p m.name }. + Tue Dec 25 03:51:55 2007 Koichi Sasada <ko1@a...> * compile.c (iseq_compile_each): fix stack consistency bug. Index: parse.y =================================================================== --- parse.y (revision 14630) +++ parse.y (revision 14631) @@ -9039,8 +9039,12 @@ } } - if (st_lookup(global_symbols.id_str, id, &data)) - return (VALUE)data; + if (st_lookup(global_symbols.id_str, id, &data)) { + VALUE str = (VALUE)data; + if (RBASIC(str)->klass == 0) + RBASIC(str)->klass = rb_cString; + return str; + } if (is_attrset_id(id)) { ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL; @@ -9053,8 +9057,12 @@ str = rb_str_dup(str); rb_str_cat(str, "=", 1); rb_intern_str(str); - if (st_lookup(global_symbols.id_str, id, &data)) - return (VALUE)data; + if (st_lookup(global_symbols.id_str, id, &data)) { + VALUE str = (VALUE)data; + if (RBASIC(str)->klass == 0) + RBASIC(str)->klass = rb_cString; + return str; + } } return 0; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml