[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: can I make a C module not get unloaded? it is (sometimes) fatal on OS X
- From: Sam Roberts <sroberts@...>
- Date: Thu, 8 Mar 2007 09:29:15 -0800
An OS X dynamically loaded shared library (aka "bundle") cannot be
unloaded if it ever called any obj-c APIs.
I got lost in the package code... is it possible in my luaopen_xxxx()
function to find the userdata that refers to my module? I would like to
remove that userdata, or at least it's metatable, so it no longer has a
finalizer, and won't do this:
objc: cannot unmap an image containing ObjC data
Program received signal SIGTRAP, Trace/breakpoint trap.
0x9083be80 in _objc_trap ()
Currently I do:
static void lua_objc_kill_dlclose(lua_State* L){
luaL_getmetatable(L, "_LOADLIB");
lua_pushnil(L);
lua_setfield(L, -2, "__gc");
}
luaopen_objc(lua_State*L) {
lua_objc_kill_dlclose(L);
... register my module....
}
However, this means that no module ever gets unloaded. I'd prefer to
make it just the objc module.
Btw, I have made obj-c bindings that do not require modification of the
lua executable, there are a "normal" lua module that can be used as
any other (directly linked in, loaded with require(), etc.). For this
reason, I don't want to hack loadlib.c either. A module shouldn't
require the language core to be modified in order to function.
Thanks,
Sam