[#37959] [Bug:trunk] I can modify literals — Yusuke ENDOH <mame@...>

遠藤です。

13 messages 2009/02/10

[#38005] Is URI.decode() broken? — MOROHASHI Kyosuke <moronatural@...>

もろはしです。いつもお世話になっております。

39 messages 2009/02/14
[#38006] Re: Is URI.decode() broken? — Nobuyoshi Nakada <nobu@...> 2009/02/14

なかだです。

[#38009] Re: Is URI.decode() broken? — "NARUSE, Yui" <naruse@...> 2009/02/14

成瀬です、

[#38016] Re: Is URI.decode() broken? — Fujioka <fuj@...> 2009/02/15

xibbarこと藤岡です。

[#38017] Re: Is URI.decode() broken? — "NARUSE, Yui" <naruse@...> 2009/02/15

成瀬です。

[#38040] Re: Is URI.decode() broken? — akira yamada / やまだあきら <akira@...> 2009/02/17

NARUSE, Yui さんは書きました:

[#38124] Re: Is URI.decode() broken? — "NARUSE, Yui" <naruse@...> 2009/03/03

成瀬です。

[#39214] Re: Is URI.decode() broken? — akira yamada / やまだあきら <akira@...> 2009/09/02

(2009年03月03日 22:45), NARUSE, Yui さんは書きました:

[#39218] Re: Is URI.decode() broken? — "NARUSE, Yui" <naruse@...> 2009/09/02

成瀬です。

[#39236] Re: Is URI.decode() broken? — Tanaka Akira <akr@...> 2009/09/05

In article <4A9E44DD.6050706@airemix.jp>,

[#39242] Re: Is URI.decode() broken? — KOSAKI Motohiro <kosaki.motohiro@...> 2009/09/07

小崎@思いつきを適当に書いてみるテスト

[#39246] Re: Is URI.decode() broken? — Tanaka Akira <akr@...> 2009/09/07

In article <20090907091830.2C7A.A69D9226@jp.fujitsu.com>,

[#38096] 多重代入やメソッド引数の展開でto_aが呼ばれます — nagachika <nagachika00@...>

nagachika と申します。

10 messages 2009/02/26

[#38098] ブロック引数と括弧・引数なしsuper — Shugo Maeda <shugo@...>

前田です。

12 messages 2009/02/27

[ruby-dev:37971] Re: [Bug:trunk] I can modify literals

From: Nobuyoshi Nakada <nobu@...>
Date: 2009-02-12 02:35:16 UTC
List: ruby-dev #37971
なかだです。

At Thu, 12 Feb 2009 10:34:51 +0900,
Yukihiro Matsumoto wrote in [ruby-dev:37969]:
>   * ObjectSpaceは裏技。やる方が悪い(からバグじゃない)
>   * 禁止できるものなら禁止した方がよい(からバグ)
> 
> の両方の考え方ができると思います。
> 
> ....
> 
> いろいろ考えましたが、過去にもObjectSpaceの「まずいこと」に
> 手当てしてきた経緯がありますし、バグとみなすことにします。で、
> その場合の修正方法ですが、freezeで構わないと思います。

freeze以前に、ObjectSpaceから不可視であるべきではないかと思いま
す。また、隠しオブジェクトから通常のStringを作るために
rb_str_replace()を使っていますが、これはintern.hで公開してもかま
わないんではないでしょうか。


Index: compile.c
===================================================================
--- compile.c	(revision 22249)
+++ compile.c	(working copy)
@@ -296,4 +296,5 @@ PRINTF_ARGS(void ruby_debug_printf(const
   (name##_body__.last = &name##_body__.anchor, name = &name##_body__)
 
+#define hide_obj(obj) (void)(RBASIC(obj)->klass = 0)
 
 #include "optinsn.inc"
@@ -2231,5 +2232,5 @@ compile_array_(rb_iseq_t *iseq, LINK_ANC
     if (opt_p == Qtrue) {
 	if (!poped) {
-	    VALUE ary = rb_ary_new();
+	    VALUE ary = rb_ary_tmp_new(len);
 	    node = node_root;
 	    while (node) {
@@ -2710,4 +2711,5 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHO
 	if (needstr != Qfalse) {
 	    VALUE str = rb_str_new2(estr);
+	    hide_obj(str);
 	    ADD_INSN1(ret, nd_line(node), putstring, str);
 	    iseq_add_mark_object_compile_time(iseq, str);
@@ -4354,4 +4356,5 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_
 	debugp_param("nd_lit", node->nd_lit);
 	if (!poped) {
+	    hide_obj(node->nd_lit);
 	    ADD_INSN1(ret, nd_line(node), putstring, node->nd_lit);
 	}
Index: string.c
===================================================================
--- string.c	(revision 22249)
+++ string.c	(working copy)
@@ -816,6 +816,4 @@ rb_obj_as_string(VALUE obj)
 }
 
-static VALUE rb_str_replace(VALUE, VALUE);
-
 VALUE
 rb_str_dup(VALUE str)
@@ -3723,5 +3721,5 @@ rb_str_gsub(int argc, VALUE *argv, VALUE
  */
 
-static VALUE
+VALUE
 rb_str_replace(VALUE str, VALUE str2)
 {
Index: insns.def
===================================================================
--- insns.def	(revision 22249)
+++ insns.def	(working copy)
@@ -374,5 +374,6 @@ putstring
 (VALUE val)
 {
-    val = rb_str_new3(str);
+    VALUE rb_str_replace(VALUE, VALUE);
+    val = rb_str_replace(rb_str_new(0, 0), str);
 }
 
@@ -461,5 +462,5 @@ duparray
 (VALUE val)
 {
-    val = rb_ary_dup(ary);
+    val = rb_ary_replace(rb_ary_new2(0), ary);
 }
 
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 22249)
+++ include/ruby/intern.h	(working copy)
@@ -618,4 +618,5 @@ VALUE rb_str_equal(VALUE str1, VALUE str
 VALUE rb_str_drop_bytes(VALUE, long);
 void rb_str_update(VALUE, long, long, VALUE);
+VALUE rb_str_replace(VALUE, VALUE);
 VALUE rb_str_inspect(VALUE);
 VALUE rb_str_dump(VALUE);


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread