lua-users home
lua-l archive

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


Wesley Smith wrote:
> Just to get back to the list on this, here's what has happened.
> On OSX 10.4, I can't find a way to get rid of the double frees just
> yet, but I don't get crashing as long as I'm very careful to wipe out
> any allocated objective C classes before unlinking the module.
> 
> On OSX 10.5, I no longer get double free warnings.  And if not careful
> can trigger crashes that look like:
> 
> =shlibs-removed,shlib-info=[num="85",name="glo.so",kind="-",dyld-addr="0xbf20000",reason="dyld",requested-state="E",state="E",path="/Users/wesleysmith/Documents/LuaAV/test/glo.so",description="/Users/wesleysmith/Documents/LuaAV/test/glo.so",loaded_addr="0xbf20000",slide="0xbf20000",prefix=""]
> Program received signal:  "EXC_BAD_ACCESS".

I recently came across double frees in one of my projects, so I'm
wondering if you might be seeing something similar.

I am using lua_newuserdata() to create myself a userdata struct that
contains various bit'n'pieces.  When I close off the resources, I had
made the error of not only freeing the various bit'n'pieces, but also
freeing the memory returned by lua_newuserdata().  This lead to a
double free for me because Lua frees the userdata memory when the GC
on this userdata is triggered.

My fix was to only free my own resources and then let Lua GC free the
userdata itself.

Robby