[#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-13 07:54:06 UTC
List: ruby-core #3384
nobu.nokada@softhome.net wrote:
(2004/09/13 00:40)

>Seems fine, but this wouldn't be needed.
>
>> --- ruby.h	7 Apr 2004 06:30:14 -0000	1.105
>> +++ ruby.h	11 Sep 2004 03:58:12 -0000
>> @@ -548,7 +548,7 @@ int rb_block_given_p _((void));
>>  VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE));
>>  VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
>>  VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
>> -VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
>> +VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),volatile VALUE));

Umm, you mean this?

Index: eval.c
===================================================================
RCS file: /var/cvs/src/ruby/eval.c,v
retrieving revision 1.695
diff -u -w -b -p -r1.695 eval.c
--- eval.c	6 Sep 2004 00:48:03 -0000	1.695
+++ eval.c	13 Sep 2004 01:25:39 -0000
@@ -5165,7 +5165,7 @@ rb_ensure(b_proc, data1, e_proc, data2)
     VALUE data2;
 {
     int state;
-    volatile VALUE result = Qnil;
+    volatile VALUE result = Qnil, dummy = data2;
     VALUE retval;
 
     PUSH_TAG(PROT_NONE);

or

Index: eval.c
===================================================================
RCS file: /var/cvs/src/ruby/eval.c,v
retrieving revision 1.695
diff -u -w -b -p -r1.695 eval.c
--- eval.c	6 Sep 2004 00:48:03 -0000	1.695
+++ eval.c	13 Sep 2004 01:29:38 -0000
@@ -5162,7 +5162,7 @@ rb_ensure(b_proc, data1, e_proc, data2)
     VALUE (*b_proc)();
     VALUE data1;
     VALUE (*e_proc)();
-    VALUE data2;
+    volatile VALUE data2;
 {
     int state;
     volatile VALUE result = Qnil;

Probably former because there is difference in type of arguments
between prototype and implementation.
(Maybe this is allowed in C, but I could not find document to confirm.
 At least C++ fails.)

///////////////////////////////////////////////////////////////////////////

But I'm still uncomfortable about volatile. ruby is large, I think we cannot
guarantee all VALUEs are guarded from compiler optimization.

I think the safest way is to store object into volatile variable just after construction.

  volatile VALUE v = rb_str_new2("foo");

  foo(v); /* don't have to think about GC */

but on this policy, we can't do this

  foo(rb_str_new2("foo"));

.... totally.


In This Thread