From 9b2e0b6ac2986489fea4d40a6ee7be21d21111a6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 8 Jun 2021 12:30:37 +0800 Subject: [PATCH] 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 --- src/rgw/rgw_lua_utils.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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) { -- 2.39.5