lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, May 06, 2004 at 05:52:33PM -0700, Quinn Tyler Jackson wrote:
> If you define l_free(pointer, oldsize) and l_realloc(pointer, oldsize,
> newsize) to refer to your own instrumentation, you can intercept all
> allocations and releases in your code to do statistics gathering.

Thanks, this seems to work.  Mostly.  There seems to be a caveat: if you
call lua_getinfo (even if 'what' is "") from within the realloc function,
then lua code mysteriously fails with "attempt to concatenate a nil value"
where no concatenation takes place that I can see.

The only place I could figure would cause this is the setnilvalue(L->top)
in info_tailcall() in ldebug.c.  Indeed, commenting this line out fixes the
problem, and my instrumentation seems to work.  So, why is that setnilvalue
call in there?

This is with Lua 5.0.2, by the way.

-Andy