From: Yukihiro Matsumoto Date: 2004-09-14T00:05:01+09:00 Subject: Re: [PATCH] dir.c --- Dir.chdir error handling Hi, In message "Re: [PATCH] dir.c --- Dir.chdir error handling" on Mon, 13 Sep 2004 23:30:06 +0900, H.Yamamoto writes: |To confirm this, we must go down function call. That is, | | void somefunc() | { | VALUE s = rb_str_new2("foo"); | | func1(s); | } | | void func1(VALUE v) /* this function doesn't protect v explicitly, so that resposibility */ | { /* is for sub functions ... */ | /* too complex codes here */ | | rb_fooboo(v); | | if (/* ...... */) | { | func2(v, -1, 2, 3); | } | else | { | func3(1, v, rb_str_new2("foo")); | } | } | |And move to func2, func3.... mostly object will be protected with volatile or |touched with OBJ_INFECT() or StringValue() somewhere, but there is possibility |none of the functions won't protect it. I think [ruby-dev:19854] is such bug. As Guy stated in [ruby-talk:03387], the VALUEs must be referenced from somewhere (even without volatile) if it's still alive (in GC sense); you don't have to worry about protection. The only exception is the usage of internal data _after_ the last reference to the VALUE. In that case, the VALUE reference might be optimized out, and GC may cause unexpected free(). Or am I missing something? matz.