[#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, =

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 =

[#31885] Avoiding $LOAD_PATH pollution — Eric Hodel <[email protected]>

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:31952] Re: Variable Allocation, Variable Reassignment, GC Pointer Testing (Was: Re: Garbage Collection Question)

From: Roger Pack <rogerdpack2@...>
Date: 2010-08-30 17:35:02 UTC
List: ruby-core #31952
>> 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 n=
ot using any C pointers for the particular example, so there is nothing els=
e 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
> =A0# demo_var is internally mapped as a pointer to the newly created Obje=
ct, which is instantiated on the heap.
> =A0demo_var =3D Object.new
> =A0# demo_var is internally mapped to 4
> =A0demo_var =3D nil
> =A0# GC, in env_mark, walks (among others) space demarcated by RubyVM::En=
v, which is defined by its length in objects (VALUE)
> =A0ObjectSpace.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 i=
s potentially a pointer pointing to the heap.
>
> So as I understand, before the GC is called here we have 2 NODE_LASGN nod=
es. Is this correct?
>
> So the first one allocates Object and assigns the reference to demo_var i=
n 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 m=
ark? It is clear that if a reference to Object is left (invisibly) on the s=
tack then it will be marked until the stack gets cleaned up. This would obv=
iously not take place until the frame is taken off the stack. But I can't f=
ind 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 ins=
truction 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 refere=
nce to Object; yet insofar as Object gets marked by gc_mark_locations (call=
ed 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.

http://timetobleed.com/what-is-a-ruby-object-introducing-memprof-dump/

might help.

Besides that just stepping through using GCC might help you.
NB that the GC marks both references from the stack and "global
rooted" objects, like code segments which might be used later.

GL.
-r

In This Thread

Prev Next