Bug correction: upvalues are removed from the stack by lua_pushcclosure, which leaves the stack with two new values (the name and the closure); the table might be just below them (top-3).