[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: OP_NEWTABLE > __gc > lua_getinfo > getfuncname fails assert
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 14 Jun 2016 12:20:36 -0300
> On Jun 13, 2016, at 4:04 PM, Sean Conner <sean@conman.org> wrote:
> >
> > I don't think that will give you any valid information. GC happens
> > asynchronously from the program (well, it can be viewed that way). For
> > instance:
> >
> > o = new_object() -- something with a metatable and a __gc method
> > o = nil
> >
> > The __gc() method isn't called when o is set to nil. It just dereferences
> > the object from it's "container" (so to speak). At some point in the
> > future, when the GC does run, the GC will notice that there are no more
> > references to the object, and then call its __gc() method. So obtaining a
> > stack trace when __gc is called isn't really a valid thing to do generally.
>
> Oh, good point! I’m logging the stack trace in realloc, and since Lua frees memory by reallocing the block to zero bytes it was logging there too. I’ll just skip the trace if size is zero. As you say, knowing where it was freed isn’t really useful.
Not being useful does not imply it should generate an error. This may
be a bug; I will check it.
-- Roberto