Lua stack corruption

brandon stevenson <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Hi guys,
I have found a stack corruption in lua that I believe is caused by
luabind. The corruption occurs in the luaexpat callback table when I
set a value to a class bound by luabind. Without setting this value
the callback table is not corrupted. Here is some relevant code, would
be great if you could help me with it.

here is the script,
----------------------------------------------------
print("-- Loading Theme --")

require "lxp"

local theme = Theme()
local curWidget = nil

local function texture(name, args)
   widget = theme : NewWidget(args["name"], nil)

    for i=1,#args do
	if args[i] == "x" then
	    --if this is commented out it works fine
	    widget[args[i]] = tonumber(args["x"])
	end
    end
end

callbacks = {
    StartElement = function (parser, name, attribs)
	print("Element:",name)
	if name == "texture" then
		print("here")
		texture(name, attribs)
	end
    end
}

parser = lxp.new(callbacks)
local file = io.open("themes/default.xml", "r")

for line in file:lines() do
    print(line)
    parser:parse(line)
    print(parser:getcallbacks()['StartElement'])
end

file:close()

print("-- Finished loading theme --")

---------------------------------------------------------------------
and the code I bind with

---------------------------------------------------------------------
	luabind::module(GetLuaState())[
		luabind::class_<Theme > ("Theme")
		.def(luabind::constructor<>())
		.def("Init", &Theme::Init)
		.def("LoadTheme", &Theme::LoadTheme)
		.def("PushWidget", &Theme::PushWidget)
		.def("NewWidget", &Theme::NewWidgetData)
		.def("NewWindow", &Theme::NewWindowData)
		.property("Image", &Theme::GetImage, &Theme::SetImage),
		
		luabind::class_<WindowData > ("WindowData")
		.def(luabind::constructor<>())
		.def_readwrite("Widgets", &WindowData::Widgets),

		luabind::class_<WidgetData > ("WidgetData")
		.def(luabind::constructor<>())
		.def_readonly("name", &WidgetData::name)
		.def_readwrite("x", &WidgetData::x)
		.def_readwrite("y", &WidgetData::y)
		.def_readwrite("width", &WidgetData::width)
		.def_readwrite("height", &WidgetData::height)
		];
-----------------------------------------------------------------------------

for more info you can look at
http://www.gamedev.net/community/forums/topic.asp?topic_id=535089

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.