[#34033] The rights of ruby-core people and Myth of ruby-dev — "NARUSE, Yui" <naruse@...>

Some of you may don't know your rights.

32 messages 2011/01/03
[#34067] Re: The rights of ruby-core people and Myth of ruby-dev — Aaron Patterson <aaron@...> 2011/01/04

On Tue, Jan 04, 2011 at 06:55:47AM +0900, NARUSE, Yui wrote:

[#34043] proposal: gem_prelude needs to die — Ryan Davis <ryand-ruby@...>

I think it is time for gem_prelude to die.

21 messages 2011/01/04
[#34077] Re: proposal: gem_prelude needs to die — Tanaka Akira <akr@...> 2011/01/05

2011/1/4 Ryan Davis <ryand-ruby@zenspider.com>:

[#34091] Moving to Git? — Lucas Nussbaum <lucas@...>

Hi,

87 messages 2011/01/05
[#34099] Re: Moving to Git? — KOSAKI Motohiro <kosaki.motohiro@...> 2011/01/05

> Hi,

[#34103] Re: Moving to Git? — "U.Nakamura" <usa@...> 2011/01/05

Hello,

[#34105] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 13:15, U.Nakamura escreveu:

[#34106] Re: Moving to Git? — "NARUSE, Yui" <naruse@...> 2011/01/05

(2011/01/06 0:46), Rodrigo Rosenfeld Rosas wrote:

[#34112] Re: Moving to Git? — Jon <jon.forums@...> 2011/01/05

> > Well, I guess I can help listing some advantages. Using git:

[#34118] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 11:28, Jon <jon.forums@gmail.com> wrote:

[#34121] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 17:16, mathew escreveu:

[#34129] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 13:23, Rodrigo Rosenfeld Rosas

[#34138] Re: Moving to Git? — Czarek <cezary.baginski@...> 2011/01/05

On Thu, Jan 06, 2011 at 06:50:24AM +0900, mathew wrote:

[#34188] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Wed, Jan 5, 2011 at 17:02, Czarek <cezary.baginski@gmail.com> wrote:

[#34191] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/06

On 07/01/11 at 01:05 +0900, mathew wrote:

[#34201] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Thu, Jan 6, 2011 at 10:36, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34206] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/07

On 07/01/11 at 08:07 +0900, mathew wrote:

[#34227] Re: Moving to Git? — mathew <meta@...> 2011/01/07

On Thu, Jan 6, 2011 at 23:50, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34231] Re: Moving to Git? — Daniel Bovensiepen <bovensiepen@...> 2011/01/07

Dear all,

[#34116] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34117] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

What kind of Redmine integration you are talking about? We use Redmine

[#34120] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34125] Re: Moving to Git? — Nikolai Weibull <now@...> 2011/01/05

On Wed, Jan 5, 2011 at 19:57, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#34124] [Ruby 1.9-Bug#4235][Open] svn keywords in code prevent correct building of ruby using git mirror — Stephen Bannasch <redmine@...>

Bug #4235: svn keywords in code prevent correct building of ruby using git mirror

12 messages 2011/01/05

[#34171] [Ruby 1.8-Feature#4239][Open] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Shota Fukumori <redmine@...>

Feature #4239: Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8?

104 messages 2011/01/06
[#34514] [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Zeno Davatz <redmine@...> 2011/01/15

Issue #4239 has been updated by Zeno Davatz.

[#34516] Re: [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — "NARUSE, Yui" <naruse@...> 2011/01/15

(2011/01/16 0:11), Zeno Davatz wrote:

[#34214] [Ruby 1.9-Feature#4247][Open] New features for Array#sample, Array#choice — Yoji Ojima <redmine@...>

Feature #4247: New features for Array#sample, Array#choice

10 messages 2011/01/07

[#34267] [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Jonas Pfenniger <redmine@...>

Feature #4254: Allow method transplanting

23 messages 2011/01/09
[#34280] Re: [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Yukihiro Matsumoto <matz@...> 2011/01/10

Hi,

[#34299] [Ruby 1.9-Bug#4256][Open] [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32] — Rama Mahendravada <redmine@...>

Bug #4256: [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

9 messages 2011/01/10

[#34318] ext/bigdecimal/lib/bigdecimal/util.rb — Aaron Patterson <aaron@...>

Hi Murata!

14 messages 2011/01/11
[#34321] Re: ext/bigdecimal/lib/bigdecimal/util.rb — Yukihiro Matsumoto <matz@...> 2011/01/11

Hi,

[#34354] [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Charles Nutter <redmine@...>

Feature #4264: General type coercion protocol for Ruby

33 messages 2011/01/11
[#34359] Re: [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Jim Weirich <jim.weirich@...> 2011/01/11

[#34355] [Ruby 1.9-Feature#4265][Open] Provide a core method Kernel#ruby for invoking a new Ruby instance — Charles Nutter <redmine@...>

Feature #4265: Provide a core method Kernel#ruby for invoking a new Ruby instance

15 messages 2011/01/11

[#34362] [Ruby 1.9-Bug#4266][Open] Timeouts in threads cause "ThreadError: deadlock; recursive locking" — Christopher Bottaro <redmine@...>

Bug #4266: Timeouts in threads cause "ThreadError: deadlock; recursive locking"

12 messages 2011/01/11

[#34399] [Ruby 1.9-Bug#4272][Open] rb_enc_str_new() causes segmentfault when using threads in parallel — Iñaki Baz Castillo <redmine@...>

Bug #4272: rb_enc_str_new() causes segmentfault when using threads in parallel

14 messages 2011/01/12

[#34534] [Ruby 1.9-Bug#4283][Open] Timeout.timeout may cause application exit unintetionally — Motohiro KOSAKI <redmine@...>

Bug #4283: Timeout.timeout may cause application exit unintetionally

11 messages 2011/01/17

[#34537] [Ruby 1.9-Bug#4285][Open] Ruby don't have asynchrounous exception safe syntax and It should have. — Motohiro KOSAKI <redmine@...>

Bug #4285: Ruby don't have asynchrounous exception safe syntax and It should have.

12 messages 2011/01/17

[#34550] [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Charles Nutter <redmine@...>

Feature #4288: Allow invoking arbitrary method names with foo."something" syntax

13 messages 2011/01/18
[#34616] Re: [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Gary Wright <gwtmp01@...> 2011/01/19

[#34577] Importing rubygems 1.5.0 (release candidate) into trunk. — Ryan Davis <ryand-ruby@...>

I'm going to be committing rubygems 1.5.0 into trunk in a bit.

13 messages 2011/01/18

[#34632] Ruby operator equivalent to Groovy's "?." — Rodrigo Rosenfeld Rosas <rr.rosas@...>

One of the few things I like in Groovy that Ruby doesn't support is

19 messages 2011/01/20

[#34634] Returning from the callee — Rodrigo Rosenfeld Rosas <rr.rosas@...>

Sometimes it is useful to be able to return from the callee method.

15 messages 2011/01/20

[#34648] [Ruby 1.9-Bug#4298][Open] Duration of calling String#[] with the same index is strangely related to string length. — Radosław Bułat <redmine@...>

Bug #4298: Duration of calling String#[] with the same index is strangely related to string length.

13 messages 2011/01/20

[#34861] [Ruby 1.9-Feature#4326][Open] Fiber should respond to call() and [] — Aaron Patterson <redmine@...>

Feature #4326: Fiber should respond to call() and []

21 messages 2011/01/26
[#34943] [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Nutter <redmine@...> 2011/01/28

Issue #4326 has been updated by Charles Nutter.

[#34954] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Aaron Patterson <aaron@...> 2011/01/28

On Sat, Jan 29, 2011 at 02:58:46AM +0900, Charles Nutter wrote:

[#34957] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Oliver Nutter <headius@...> 2011/01/29

On Fri, Jan 28, 2011 at 5:29 PM, Aaron Patterson

[#34869] make ruby support line continuations ? — Marc Chantreux <khatar@...>

hello,

22 messages 2011/01/26
[#34878] Re: make ruby support line continuations ? — Jim Freeze <jimfreeze@...> 2011/01/26

> I love it so much i tried it in ruby. trying to rewrite:

[#34887] Re: make ruby support line continuations ? — Marc Chantreux <khatar@...> 2011/01/27

hello,

[#34889] Re: make ruby support line continuations ? — V咜 Ondruch <v.ondruch@...> 2011/01/27

Dne 27.1.2011 7:15, Marc Chantreux napsal(a):

[#34911] The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...>

(I sent this before I subscribed and I'm not sure if it bounced. Sorry if

21 messages 2011/01/27
[#34912] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

RVM is not official, and makes problem more difficult. (magically

[#34913] Re: The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...> 2011/01/27

What do you mean by "official"? Also, what does it make more difficult? Do

[#34914] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

return mail is gmail thing. I have same problem.

[#34970] [Ruby 1.9-Bug#4343][Open] Dir.glob does match files without extension — Vit Ondruch <redmine@...>

Bug #4343: Dir.glob does match files without extension

26 messages 2011/01/29
[#34975] [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Nobuyoshi Nakada <redmine@...> 2011/01/29

Issue #4343 has been updated by Nobuyoshi Nakada.

[#34978] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:19 AM, Nobuyoshi Nakada wrote:

[#34979] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:27, Jeremy Bopp napsal(a):

[#34981] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:33 AM, Vテュt Ondruch wrote:

[#34982] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:53, Jeremy Bopp napsal(a):

[ruby-core:34114] [Ruby 1.9-Bug#4168] WeakRef is unsafe to use in Ruby 1.9

From: Brian Durand <redmine@...>
Date: 2011-01-05 18:00:42 UTC
List: ruby-core #34114
Issue #4168 has been updated by Brian Durand.

File weakref.rb added
File weakref_patch.diff added

I found what may be a bug in my patch. When testing similar code on Rubinius, I found the process deadlocking. I believe what was happening is that a thread was stopped in order to run garbage collection when it was inside a synchronize block on a monitor. On garbage collection the finalizers were run which locks on the same monitor to cleanup weak references which resulted in the deadlock and hung process. Can anyone shed some light on if this might be a problem with the garbage collector in YARV? I've attached updated patch files that removes the synchronization in the finalizers and is should still be thread safe.

Also, I believe there are really two issues and that #2 could use some more discussion (and maybe a ticket of its own):

1. BUG - WeakRef is broken on YARV 1.9
2. ENHANCEMENT - The Ruby specification should include a WeakReference and SoftReference implementation

Because soft and weak referencers are fairly tightly tied to the VM's memory manager, having them as part of the specification would make it easier for gem authors to count on them being present and having a consistent interface. I'm not as sure about the utility of phantom references or porting reference queues straight from Java. I'm not sure they fit into Ruby the same way they fit into Java. Specifically, is there a difference in Ruby between a weak reference and a phantom reference with the way Ruby finalizers work and is there a better Rubyesque interface for reference queues given the way finalizers can be attached to objects?

I don't think WeakRef should be the standard going forward because it encourages buggy code by mixing in the delegator pattern. If you want to safely use a weakly referenced object, you should first establish a strong reference to it. Once you have this strong reference, there is no reason to use a delegate anymore.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/4168

----------------------------------------
http://redmine.ruby-lang.org

Attachments (2)

weakref.rb (4.97 KB, text/x-ruby-script)
require 'monitor'

# WeakReference is a class to represent a reference to an object that is not seen by
# the tracing phase of the garbage collector.  This allows the referenced
# object to be garbage collected as if nothing is referring to it.
#
# The difference between this class and WeakRef is that this class does not
# use the delegator pattern and so has an interface more suited for detecting
# if the referenced object has been reclaimed.
#
# Usage:
#
#   foo = Object.new
#   ref = WeakReference.new(foo)
#   ref.object			# should be foo
#   ObjectSpace.garbage_collect
#   ref.object			# should be nil
class WeakReference
  attr_reader :referenced_object_id
  
  # Map of references to the object_id's they refer to.
  @@referenced_object_ids = {}

  # Map of object_ids to references to them.
  @@object_id_references = {}

  @@monitor = Monitor.new

  # Finalizer that cleans up weak references when an object is destroyed.
  @@object_finalizer = lambda do |object_id|
    reference_ids = @@object_id_references.delete(object_id)
    if reference_ids
  	  reference_ids.each do |reference_object_id|
  	    @@referenced_object_ids.delete(reference_object_id)
  	  end
	  end
  end

  # Finalizer that cleans up weak references when references are destroyed.
  @@reference_finalizer = lambda do |object_id|
    referenced_id = @@referenced_object_ids.delete(object_id)
    if referenced_id
      obj = ObjectSpace._id2ref(referenced_object_id) rescue nil
      if obj
        backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
        if backreferences
          backreferences.delete(object_id)
          obj.send(:remove_instance_variable, :@__weak_backreferences__) if backreferences.empty?
        end
      end
      references = @@object_id_references[referenced_id]
      if references
        references.delete(object_id)
    	  @@object_id_references.delete(referenced_id) if references.empty?
  	  end
	  end
  end

  # Create a new weak reference to an object. The existence of the weak reference
  # will not prevent the garbage collector from reclaiming the referenced object.
  def initialize(obj)
    @referenced_object_id = obj.__id__
    ObjectSpace.define_finalizer(obj, @@object_finalizer)
    ObjectSpace.define_finalizer(self, @@reference_finalizer)
    @@monitor.synchronize do
      @@referenced_object_ids[self.__id__] = obj.__id__
      add_backreference(obj)
      references = @@object_id_references[obj.__id__]
      unless references
        references = []
        @@object_id_references[obj.__id__] = references
      end
      references.push(self.__id__)
    end
  end

  # Get the reference object. If the object has already been garbage collected,
  # then this method will return nil.
  def object
    obj = nil
    begin
      if referenced_object_id == @@referenced_object_ids[self.object_id]
        obj = ObjectSpace._id2ref(referenced_object_id)
        obj = nil unless verify_backreferences(obj)
      end
    rescue RangeError
      # Object has been garbage collected.
    end
    obj
  end

  private

    def add_backreference(obj)
      backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
      unless backreferences
        backreferences = []
        obj.instance_variable_set(:@__weak_backreferences__, backreferences)
      end
      backreferences << object_id
    end

    def verify_backreferences(obj)
      backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
      backreferences && backreferences.include?(object_id)
    end
end

require "delegate"

# WeakRef is a class to represent a reference to an object that is not seen by the tracing
# phase of the garbage collector. This allows the referenced object to be garbage collected
# as if nothing is referring to it. Because WeakRef delegates method calls to the referenced
# object, it may be used in place of that object, i.e. it is of the same duck type.
#
# If you don't need to use the delegator pattern, you can use WeakReference instead.
#
# Usage:
#   foo = Object.new
#   foo = Object.new
#   p foo.to_s			# original's class
#   foo = WeakRef.new(foo)
#   p foo.to_s			# should be same class
#   ObjectSpace.garbage_collect
#   p foo.to_s			# should raise exception (recycled)
class WeakRef < Delegator
  class RefError < StandardError
  end
  
  def initialize(obj)
    super
  end
  
  def __getobj__
    obj = @reference.object
    Kernel::raise(RefError, "Invalid Reference - probably recycled", Kernel::caller(1)) unless obj
    obj
  end
  
  def __setobj__(obj)
    @reference = WeakReference.new(obj)
  end
  
  def weakref_alive?
    !!@reference.object
  end
end

if __FILE__ == $0
  foo = Object.new
  p foo.to_s			# original's class
  foo = WeakRef.new(foo)
  p foo.to_s			# should be same class
  ObjectSpace.garbage_collect
  ObjectSpace.garbage_collect
  p foo.to_s			# should raise exception (recycled)
end
weakref_patch.diff (3.99 KB, text/x-diff)
13c13
< require 'thread'
---
> require 'monitor'
22,30c22,42
<   @@mutex = Mutex.new
<   @@final = lambda {|id|
<     @@mutex.synchronize {
<       rids = @@id_map[id]
<       if rids
< 	for rid in rids
< 	  @@id_rev_map.delete(rid)
< 	end
< 	@@id_map.delete(id)
---
>   @@monitor = Monitor.new
> 
>   @@object_finalizer = lambda do |id|
>     rids = @@id_map.delete(id)
>     if rids
>       rids.each do |rid|
>         @@id_rev_map.delete(rid)
>       end
>     end
>   end
>   
>   @@reference_finalizer = lambda do |id|
>     rid = @@id_rev_map.delete(id)
>     if rid
>       obj = ObjectSpace._id2ref(referenced_object_id) rescue nil
>       if obj
>         backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
>         if backreferences
>           backreferences.delete(object_id)
>           obj.send(:remove_instance_variable, :@__weak_backreferences__) if backreferences.empty?
>         end
32,36c44,47
<       rid = @@id_rev_map[id]
<       if rid
< 	@@id_rev_map.delete(id)
< 	@@id_map[rid].delete(id)
< 	@@id_map.delete(rid) if @@id_map[rid].empty?
---
>       refs = @@id_map[rid]
>       if refs
>         refs.delete(id)
>         @@id_map.delete(rid) if refs.empty?
38,39c49,50
<     }
<   }
---
>     end
>   end
42,45c53,56
<     @__id = orig.object_id
<     ObjectSpace.define_finalizer orig, @@final
<     ObjectSpace.define_finalizer self, @@final
<     @@mutex.synchronize {
---
>     @__id = orig.__id__
>     ObjectSpace.define_finalizer orig, @@object_finalizer
>     ObjectSpace.define_finalizer self, @@reference_finalizer
>     @@monitor.synchronize do
47,49c58,61
<     }
<     @@id_map[@__id].push self.object_id
<     @@id_rev_map[self.object_id] = @__id
---
>       @@id_map[@__id].push self.__id__
>       @@id_rev_map[__id__] = @__id
>       __add_weakref_backreference__(orig)
>     end
54,56c66
<     unless @@id_rev_map[self.object_id] == @__id
<       Kernel::raise RefError, "Invalid Reference - probably recycled", Kernel::caller(2)
<     end
---
>     obj = nil
58c68,71
<       ObjectSpace._id2ref(@__id)
---
>       if @@id_rev_map[self.__id__] == @__id
>         obj = ObjectSpace._id2ref(@__id)
>         obj = nil unless __verify_weakref_backreference__(obj)
>       end
60c73
<       Kernel::raise RefError, "Invalid Reference - probably recycled", Kernel::caller(2)
---
>       # Object has been garbage collected.
61a75,76
>     Kernel::raise(RefError, "Invalid Reference - probably recycled", Kernel::caller(1)) unless obj
>     obj
62a78
>   
67c83,90
<     @@id_rev_map[self.object_id] == @__id
---
>     if @@id_rev_map[self.__id__] == @__id
>       obj = ObjectSpace._id2ref(@__id)
>       __verify_weakref_backreference__(obj)
>     else
>       false
>     end
>   rescue RangeError
>     false
68a92,113
>   
>   private
> 
>     # Add a backreference to the weakref object id in the referenced object to protect
>     # against the object id being recycled before the finalizers have a chance to run.
>     def __add_weakref_backreference__(obj)
>       backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
>       unless backreferences
>         backreferences = []
>         obj.instance_variable_set(:@__weak_backreferences__, backreferences)
>       end
>       backreferences << object_id
>     end
> 
>     # Verify that the object is the one the weakref thinks it is. On runtimes where
>     # object ids are recycled after garbage collection and reallocated to new objects,
>     # there is a chance that the reference could find an object at the specified
>     # location in the ObjectSpace that is not the one it originally referenced.
>     def __verify_weakref_backreference__(obj)
>       backreferences = obj.instance_variable_get(:@__weak_backreferences__) if obj.instance_variable_defined?(:@__weak_backreferences__)
>       backreferences && backreferences.include?(self.__id__)
>     end
72c117
< #  require 'thread'
---
>   #  require 'thread'

In This Thread