Hi Yegappan,

2016/8/19 Fri 23:08:16 UTC+9 [email protected] wrote:
> Hi all,
> 
> On Thu, Aug 18, 2016 at 5:47 AM, Yegappan Lakshmanan
> <[email protected]> wrote:
> > Hi all,
> >
> > The attached patch adds support for setting and getting a context to/from
> > a quickfix/location list. There is a refcount problem with this diff (which 
> > I am
> > not able to solve).
> >
> > If the context is a number or a string, then the patch works without any
> > issues. If the context is a List or a Dict, then Vim crashes if garbage
> > collection runs. For example, the following works:
> >
> >     :call setqflist([], 'a', {'context':[1,2,3]})
> >     :echo getqflist({'context':1})
> >
> > But the following doesn't work:
> >
> >     :call setqflist([], 'a', {'context':[1,2,3]})
> >     :call garbagecollect()
> >     :echo getqflist({'context':1})
> >
> > Any suggestions on how to copy the context with proper update to the
> > reference count so that garbage collection doesn't free the List/Dict?
> 
> Any suggestions on how to fix the reference count issue?

I struggled with reference counting and garbage collection when I implemented
lambda and closure.

Vim uses mark-and-sweep garbage collection. If an object is not marked, it
will be collected even if the refcount is not zero. This is needed because
reference counting cannot handle circular reference. To mark an object, you
need to update the copyID member in the object (dict or list).
Please check the garbage_collect() function in eval.c and also
set_ref_in_XXX() functions.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui