[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Bug in lua_getfield() ?
- From: Petr Stetiar <ynezz@...>
- Date: Sun, 25 Mar 2007 23:19:20 +0200
Hi all,
first of all I would like to thank you for a great scripting language.
I'm facing some strange behavior of embedd Lua in one of my projects. (For
currious it's a wrapper around Internet Explorer completly driven by Lua).
The problem occurs in part, where I've exposed all possible IE events to Lua.
Event is just global function in Lua. So for example if I wan't to know when
the downloading of page begins I just put 'gabenie_event_download_begin()'
function in Lua script file and do the handling of the event in Lua.
If I've defined function body for all the events(more then 30) in Lua it work
as expected. The problem in Lua occurs when I've for example defined function
body for just one event.
Working 'gabenie.lua' sample:
if gabenie ~= nil then
function gabenie_event_download_begin() end -- event number 1
... snip ...
function gabenie_event_document_complete() end -- event number 30+
end
Not working 'gabenie.lua' sample:
---------------------------------
if gabenie ~= nil then
function gabenie_event_download_begin() end
end
The problem happens in my C lua_get_function(), which calls lua_getfield()
about 200 times per minute.
int lua_get_function(char *function)
{
... snip ...
lua_getfield(L, LUA_GLOBALSINDEX, function);
... snip ...
}
The call stack is:
------------------
lua_getfield() {
luaV_gettable() {
setobj2s() {
...snip...
o1->value = o2->value; [1]
...snip...
}
}
}
1 - Here sometimes happen memory corruption if there is missing event function in
Lua script. If the function body is in Lua script all works fine.
I would like to send a patch for this, but I'm using Lua for ~2 months so I
don't know much about it's internals yet to do so :-)
-- ynezz