]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: cloud sync: fix crash due to objs on cr stack 51136/head
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 26 Aug 2022 13:49:01 +0000 (09:49 -0400)
committerRamin Najjarbashi <ramin.najarbashi@gmail.com>
Tue, 18 Apr 2023 15:19:36 +0000 (18:49 +0330)
Fixes: https://tracker.ceph.com/issues/57306
When passing objects that are declared on the stack (as ref / ptr), called
cr can't access them (other than for initialization), as the yield destroys
them. We now keep these objects as class members.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_aws.cc

index 3ea5b4d8a63c1babc85da4eb0f8dd5b0dde7ca4c..1eb0bd7e905b6a9ec4d85a8c4b956078fd36b5ad 100644 (file)
@@ -1594,6 +1594,13 @@ class RGWAWSHandleRemoteObjCBCR: public RGWStatRemoteObjCBCR {
     }
   } result;
 
+  rgw_bucket target_bucket;
+  std::unique_ptr<rgw::sal::RadosBucket> bucket;
+  std::unique_ptr<rgw::sal::RadosObject> src_obj;
+  std::unique_ptr<rgw::sal::RadosBucket> dest_bucket;
+  std::unique_ptr<rgw::sal::RadosObject> dest_obj;
+
+
 public:
   RGWAWSHandleRemoteObjCBCR(RGWDataSyncCtx *_sc,
                             rgw_bucket_sync_pipe& _sync_pipe,
@@ -1672,16 +1679,14 @@ public:
       }
 
       yield {
-       rgw::sal::RadosBucket bucket(sync_env->store, src_bucket);
-        rgw::sal::RadosObject src_obj(sync_env->store, key, &bucket);
+        bucket.reset(new rgw::sal::RadosBucket(sync_env->store, src_bucket));
+        src_obj.reset(new rgw::sal::RadosObject(sync_env->store, key, bucket.get()));
 
         /* init output */
-        rgw_bucket target_bucket;
         target_bucket.name = target_bucket_name; /* this is only possible because we only use bucket name for
                                                     uri resolution */
-       rgw::sal::RadosBucket dest_bucket(sync_env->store, target_bucket);
-        rgw::sal::RadosObject dest_obj(sync_env->store, rgw_obj_key(target_obj_name), &dest_bucket);
-
+        dest_bucket.reset(new rgw::sal::RadosBucket(sync_env->store, target_bucket));
+        dest_obj.reset(new rgw::sal::RadosObject(sync_env->store, rgw_obj_key(target_obj_name), dest_bucket.get()));
 
         rgw_sync_aws_src_obj_properties src_properties;
         src_properties.mtime = mtime;
@@ -1691,10 +1696,10 @@ public:
         src_properties.versioned_epoch = versioned_epoch;
 
         if (size < instance.conf.s3.multipart_sync_threshold) {
-          call(new RGWAWSStreamObjToCloudPlainCR(sc, source_conn, &src_obj,
+          call(new RGWAWSStreamObjToCloudPlainCR(sc, source_conn, src_obj.get(),
                                                  src_properties,
                                                  target,
-                                                 &dest_obj));
+                                                 dest_obj.get()));
         } else {
           rgw_rest_obj rest_obj;
           rest_obj.init(key);
@@ -1702,8 +1707,8 @@ public:
             ldpp_dout(dpp, 0) << "ERROR: failed to decode rest obj out of headers=" << headers << ", attrs=" << attrs << dendl;
             return set_cr_error(-EINVAL);
           }
-          call(new RGWAWSStreamObjToCloudMultipartCR(sc, sync_pipe, instance.conf, source_conn, &src_obj,
-                                                     target, &dest_obj, size, src_properties, rest_obj));
+          call(new RGWAWSStreamObjToCloudMultipartCR(sc, sync_pipe, instance.conf, source_conn, src_obj.get(),
+                                                     target, dest_obj.get(), size, src_properties, rest_obj));
         }
       }
       if (retcode < 0) {