From: Kefu Chai Date: Tue, 8 Jun 2021 04:30:37 +0000 (+0800) Subject: rgw/rgw_lua_utils: return error using luaL_error() X-Git-Tag: v17.1.0~1715^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9b2e0b6ac2986489fea4d40a6ee7be21d21111a6;p=ceph-ci.git rgw/rgw_lua_utils: return error using luaL_error() it's found on aarch64, the exception is not caught even if we do catch exactly the same type of thrown exception, and the uncaught exception ends up with a std::terminate() call. it could be the ABI mismatch in aarch64, so the C++ runtime failed to find the catch block. in this change, luaL_error() is used to populate the error to the caller instead to workaround this issue. Signed-off-by: Kefu Chai --- diff --git a/src/rgw/rgw_lua_utils.h b/src/rgw/rgw_lua_utils.h index 47f7437f3ab..53b6cfc28f2 100644 --- a/src/rgw/rgw_lua_utils.h +++ b/src/rgw/rgw_lua_utils.h @@ -149,22 +149,19 @@ struct EmptyMetaTable { // by default everythinmg is "readonly" // to change, overload this function in the derived static int NewIndexClosure(lua_State* L) { - throw std::runtime_error("trying to write to readonly field"); - return NO_RETURNVAL; + return luaL_error(L, "trying to write to readonly field"); } // by default nothing is iterable // to change, overload this function in the derived static int PairsClosure(lua_State* L) { - throw std::runtime_error("trying to iterate over non-iterable field"); - return ONE_RETURNVAL; + return luaL_error(L, "trying to iterate over non-iterable field"); } // by default nothing is iterable // to change, overload this function in the derived static int LenClosure(lua_State* L) { - throw std::runtime_error("trying to get length of non-iterable field"); - return ONE_RETURNVAL; + return luaL_error(L, "trying to get length of non-iterable field"); } static void throw_unknown_field(const std::string& index, const std::string& table) {