[#7978] Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...>

This patch adds support for getting the uid and gid of the peer

27 messages 2006/06/09
[#8004] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/16

In article <200606091528.30171.jfh@cise.ufl.edu>,

[#8005] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/06/16

On Friday 16 June 2006 11:51, Tanaka Akira wrote:

[#8010] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/17

In article <200606161327.35948.jfh@cise.ufl.edu>,

[#8191] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/10

On Saturday 17 June 2006 06:27, Tanaka Akira wrote:

[#8193] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...> 2006/07/11

In article <200607101352.16804.jfh@cise.ufl.edu>,

[#8212] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/13

On Tuesday 11 July 2006 00:10, Tanaka Akira wrote:

[#8217] Re: Patch for Unix socket peer credentials — nobu@... 2006/07/14

Hi,

[#8257] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/18

On Thursday 13 July 2006 22:48, nobu@ruby-lang.org wrote:

[#8258] Re: Patch for Unix socket peer credentials — Eric Hodel <drbrain@...7.net> 2006/07/18

On Jul 18, 2006, at 12:27 PM, James F. Hranicky wrote:

[#8073] 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...>

Solaris 10

23 messages 2006/06/27
[#8074] Re: 1.8.5p1 build failure on Solaris 10 — Yukihiro Matsumoto <matz@...> 2006/06/28

Hi,

[#8078] Re: 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...> 2006/06/28

Yukihiro Matsumoto wrote:

[#8079] Re: 1.8.5p1 build failure on Solaris 10 — ts <decoux@...> 2006/06/28

>>>>> "D" == Daniel Berger <Daniel.Berger@qwest.com> writes:

[#8096] Re: 1.8.5p1 build failure on Solaris 10 — ville.mattila@... 2006/06/29

ts <decoux@moulon.inra.fr> wrote on 28.06.2006 17:37:00:

Validity of local VALUEs

From: "Hisham Muhammad" <hisham.hm@...>
Date: 2006-06-11 20:34:50 UTC
List: ruby-core #7982
Hi,

I've been wondering about the lifetime of Ruby objects declared from C
functions. Assume I create a new object through the C API (say, with
rb_class_new_instance or rb_ary_new) without exporting it to Ruby or
marking it as a global with rb_global_variable. I would expect that
this object might be garbage-collected during the execution of my C
function, making the VALUE invalid. I tried to write a small test case
that caused this:

#include <ruby.h>

static VALUE a_class;
static ID a_method_ID;

static VALUE a_method(VALUE self) {
   VALUE an_object;
   VALUE will_i_get_this;
   int i;

   /* Create a Ruby object, but don't bind it anywhere */
   an_object = rb_class_new_instance(0, NULL, a_class);
   rb_iv_set(an_object, "@an_attribute", rb_str_new2("42"));

   /* Cause some garbage collection cycles */
   for (i = 0; i < 100000; i++) {
      VALUE some_garbage = rb_ary_new();
      rb_ary_push(some_garbage, rb_str_new2("666"));
      /* Looking at the object counts, gc is really happening */
      rb_eval_string("print 'objects: ', ObjectSpace.each_object {}, '\n'");
   }

   /* I'd expect an_object to have been collected by now */
   will_i_get_this = rb_iv_get(an_object, "@an_attribute");
   fprintf(stderr, "The answer is %s.\n", RSTRING(will_i_get_this)->ptr);
}

int main(int argc, char** argv) {
   VALUE an_instance;
   ruby_init();
   a_class = rb_define_class("RubyGcTest", rb_cObject);
   rb_define_method(a_class, "a_method", a_method, 0);
   an_instance = rb_class_new_instance(0, NULL, a_class);
   a_method_ID = rb_intern("a_method");
   rb_funcall2(an_instance, a_method_ID, 0, NULL);
   ruby_finalize();
   return 0;
}

I would expect this to crash, but it doesn't. Looking at the object
counts returned by ObjectSpace.each_object, I can see that several gc
cycles are taking place. However, an_object is still valid by the end
of the function. Is this working "by chance"? From the observation
that I don't have 100000 array objects in the ObjectSpace after
calling rb_ary_new 100000 times, I gather that VALUEs do not remain
valid until the end of the function without being bound somewhere.
However, my calls to an_object are still returning the correct value.

Thanks in advance,

-- Hisham

In This Thread

Prev Next