]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_lua_utils: return error using luaL_error()
authorKefu Chai <kchai@redhat.com>
Tue, 8 Jun 2021 04:30:37 +0000 (12:30 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 8 Jun 2021 04:44:35 +0000 (12:44 +0800)
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 <kchai@redhat.com>
src/rgw/rgw_lua_utils.h

index 47f7437f3ab499f9ed5b13125a69edb9049482b5..53b6cfc28f2b54cee1437d4ba8f589cdb00c2380 100644 (file)
@@ -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) {