[Sputnik-list] [BUG] Saci/Node

Jim Whitehead II jnwhiteh at gmail.com
Tue May 13 12:34:55 GMT+2 2008


There is a rather nasty bug in saci/node.lua that causes a C stack
blowout, if the data returned from the underlying versium layer
doesn't evaluate into a Lua table.  The offending line is
saci/node.lua:94:

93: node.raw_values = saci.sandbox.new():do_lua(args.data)
94: assert(node.raw_values), "the sandbox should give us a table")

Due to the __index metamethod of the Node table:

local Node = {}
local Node_mt = {
   __index = function(t,key)
                return t.active_values[key] or t.inherited_values[key]
                       or t.raw_values[key] or Node[key]
   end
}

Obviously this will recurse forever, or at least until the stack blows
out.  The fix is to use rawget:

assert(rawget(node, "raw_values"), "the sandbox should give us a table")

This one has bitten me a number of times, but I finally figured out
what exactly was causing it.

- Jim



More information about the Sputnik-list mailing list