lua-users home
lua-l archive

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



On Mon, Nov 28, 2011 at 8:25 PM, Jose <jmalv04@gmail.com> wrote:
I''ve converted a C example that uses Linux signals and getaddrinfo_a to LuaJIT.

The example works but I get a double free corruption sometimes. Could
anybody help me identify
where I deviate from LuaJIT best practices ?

The .lj file has the LuaJIT code. The .cdef file has the C definitions.

The attached C example is taken from
http://www.hrozkovi.cz/?p=learning/.git;a=blob;f=getaddrinfo_a/gaia.c

Thanks
jose


If you add collectgarbage() after the request stage and before get replies you get a free error every time - storing a pointer to a Lua reference in a C struct does not stop Lua freeing it... You allocate host2.ar_name for example as a copy of query (you can just use query directly here) and so that gets garbage collected.

Justin