[#31647] [Backport #3666] Backport of r26311 (Bug #2587) — Luis Lavena <redmine@...>

Backport #3666: Backport of r26311 (Bug #2587)

13 messages 2010/08/07

[#31666] [Bug #3677] unable to run certain gem binaries' in windows 7 — Roger Pack <redmine@...>

Bug #3677: unable to run certain gem binaries' in windows 7

10 messages 2010/08/10

[#31676] [Backport #3680] Splatting calls to_ary instead of to_a in some cases — Tomas Matousek <redmine@...>

Backport #3680: Splatting calls to_ary instead of to_a in some cases

10 messages 2010/08/11

[#31681] [Bug #3683] getgrnam on computer with NIS group (+)? — Rocky Bernstein <redmine@...>

Bug #3683: getgrnam on computer with NIS group (+)?

13 messages 2010/08/11

[#31843] Garbage Collection Question — Asher <asher@...>

This question is no doubt a function of my own lack of understanding, but I think that asking it will at least help some other folks see what's going on with the internals during garbage collection.

17 messages 2010/08/25
[#31861] Re: Garbage Collection Question — Roger Pack <rogerdpack2@...> 2010/08/26

> The question in short: when an object goes out of scope and has no

[#31862] Re: Garbage Collection Question — Asher <asher@...> 2010/08/26

Right - so how does a pointer ever get off the stack?

[#31873] Re: Garbage Collection Question — Kurt Stephens <ks@...> 2010/08/27

On 8/26/10 11:51 AM, Asher wrote:

[#31894] Re: Garbage Collection Question — Asher <asher@...> 2010/08/27

I very much appreciate the response, and this is helpful in describing the narrative, but it's still a few steps behind my question - but it may very well have clarified some points that help us get there.

[#31896] Re: Garbage Collection Question — Evan Phoenix <evan@...> 2010/08/27

You have introduced something called a "root node" without defining it. What do you mean by this?

[#31885] Avoiding $LOAD_PATH pollution — Eric Hodel <drbrain@...7.net>

Last year Nobu asked me to propose an API for adding an object to

21 messages 2010/08/27

[#31947] not use system for default encoding — Roger Pack <rogerdpack2@...>

It strikes me as a bit "scary" to use system locale settings to

19 messages 2010/08/30

[#31971] Change Ruby's License to BSDL + Ruby's dual license — "NARUSE, Yui" <naruse@...>

Ruby's License will change to BSDL + Ruby's dual license

16 messages 2010/08/31

[ruby-core:31939] Variable Allocation, Variable Reassignment, GC Pointer Testing (Was: Re: Garbage Collection Question)

From: Asher <asher@...>
Date: 2010-08-30 03:46:18 UTC
List: ruby-core #31939
On Aug 27, 2010, at 12:33 PM, Asher wrote:

> I want to know "where" on the C stack this "might" remain. It shouldn't be an obtuse question - Ruby is allocating each and every object, and I'm not using any C pointers for the particular example, so there is nothing else in my C stack (in this case, "I" don't have a C stack, only Ruby does). 


So my question comes down to:

def random_method
  # demo_var is internally mapped as a pointer to the newly created Object, which is instantiated on the heap.  
  demo_var = Object.new
  # demo_var is internally mapped to 4
  demo_var = nil
  # GC, in env_mark, walks (among others) space demarcated by RubyVM::Env, which is defined by its length in objects (VALUE)
  ObjectSpace.garbage_collect
end

So the environment's memory space is evaluated as a series of long values (which were allocated during the compilation of the iseq), each of which is potentially a pointer pointing to the heap. 

So as I understand, before the GC is called here we have 2 NODE_LASGN nodes. Is this correct? 

So the first one allocates Object and assigns the reference to demo_var in the local var table on the stack. 

The second one assigns demo_var in the local var table on the stack to 4. 

So where does the GC discover a reference to Object to test in order to mark? It is clear that if a reference to Object is left (invisibly) on the stack then it will be marked until the stack gets cleaned up. This would obviously not take place until the frame is taken off the stack. But I can't find anywhere that this would make sense. The only place that I see where a reference occurs that the GC is walking is in the locals table. But the instruction for NODE_LASGN (setlocal) changes the pointer value for the local variable reference. So there _shouldn't_, so far as I can tell, be a reference to Object; yet insofar as Object gets marked by gc_mark_locations (called by gc_env_mark), it has a reference still existing. 

Can anyone help me find where this reference is occurring? My read of the code suggests that the GC should get "4" for the slot that would have been a pointer to Object, yet this isn't what happens. 

Insight appreciated.

Asher

In This Thread