[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: OP_NEWTABLE > __gc > lua_getinfo > getfuncname fails assert
- From: Dave Hayden <dave@...>
- Date: Mon, 13 Jun 2016 16:27:29 -0700
On Jun 13, 2016, at 4:04 PM, Sean Conner <email@example.com> 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
> 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.