[#3419] Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...>

Hello list,

19 messages 2004/09/17
[#3422] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3423] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 12:01, ts wrote:

[#3424] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3425] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 12:37, ts wrote:

[#3426] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3428] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 13:05, ts wrote:

[#3429] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

Re: [PATCH] dir.c --- Dir.chdir error handling

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2004-09-15 04:44:44 UTC
List: ruby-core #3399
> Sincerely, I really don't understand : [ruby-dev:19854] is a case of
> "inline expansion"

> Like matz said, perhaps some where there is a VALUE which must be
> protected (see the last example with Bignum#&, Bignum#|)

OK, so why are these functions not volatiled like [ruby-dev:19854] or Bignum#&, Bignum#|?
To my eyes, it looks similar. 

VALUE
rb_str_intern(str)
    VALUE str;
{
    ID id;

    if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) {
	rb_raise(rb_eArgError, "interning empty string");
    }
    if (strlen(RSTRING(str)->ptr) != RSTRING(str)->len)
	rb_raise(rb_eArgError, "symbol string may not contain `\\0'");
    id = rb_intern(RSTRING(str)->ptr);
    return ID2SYM(id);
}

int
rb_str_cmp(str1, str2)
    VALUE str1, str2;
{
    long len;
    int retval;

    len = lesser(RSTRING(str1)->len, RSTRING(str2)->len);
    retval = rb_memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
    if (retval == 0) {
	if (RSTRING(str1)->len == RSTRING(str2)->len) return 0;
	if (RSTRING(str1)->len > RSTRING(str2)->len) return 1;
	return -1;
    }
    if (retval > 0) return 1;
    return -1;
}

>H> And [ruby-talk:68531] or [ruby-talk:110826]. (nobu said this can be
>H> gcc's bug though) 
>
> The problem with such examples is that only *one* person can reproduce
> it. Difficult to say something about it.

Yes, I couldn't reproduce that in my gcc (2.9 in beos)...
And even this code didn't crash.

Index: string.c
===================================================================
RCS file: /var/cvs/src/ruby/string.c,v
retrieving revision 1.197
diff -u -w -b -p -r1.197 string.c
--- string.c	19 Aug 2004 07:33:14 -0000	1.197
+++ string.c	15 Sep 2004 04:39:13 -0000
@@ -4585,10 +4585,22 @@ rb_str_setter(val, id, var)
  *     
  */
 
+static VALUE
+string_s_string(VALUE self)
+{
+    VALUE str = rb_str_new2("foo");
+    rb_gc();
+    puts(RSTRING(str)->ptr);
+    return Qnil;
+}
+
 void
 Init_String()
 {
     rb_cString  = rb_define_class("String", rb_cObject);
+
+    rb_define_method(rb_cString, "test", string_s_string, 0);
+
     rb_include_module(rb_cString, rb_mComparable);
     rb_include_module(rb_cString, rb_mEnumerable);
     rb_define_alloc_func(rb_cString, str_alloc);

////////////////////////
// Execute

E:\ruby-cvs\win32>miniruby -e "100.times { 'test'.test }"



In This Thread