[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Cocoa (ObjC) in Lua modules
- From: Robert Raschke <rrlua@...>
- Date: Tue, 15 Jan 2008 11:22:47 +0000
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:
> 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