All of lore.kernel.org
 help / color / mirror / Atom feed
* why do we delete target in RGWGetObjLayout constructed function?
@ 2017-03-17  9:58 liuchang0812
  2017-03-17 10:08 ` liuchang0812
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: liuchang0812 @ 2017-03-17  9:58 UTC (permalink / raw)
  To: ceph-devel

I saw this problem when i read RGW source code. It seems that that
`delete` a nullptr will segment fault.

code[1]:

class RGWGetObjLayout : public RGWOp {
   protected:
        RGWRados::Object *target{nullptr};
        RGWObjManifest *manifest{nullptr};
        rgw_raw_obj head_obj;
    public:
         RGWGetObjLayout() {
             delete target;
   }


[1]. https://github.com/ceph/ceph/blob/master/src/rgw/rgw_op.h#L1777

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why do we delete target in RGWGetObjLayout constructed function?
  2017-03-17  9:58 why do we delete target in RGWGetObjLayout constructed function? liuchang0812
@ 2017-03-17 10:08 ` liuchang0812
       [not found] ` <13a064ed-c7b9-c495-ee36-246583eea4e1@redhat.com>
  2017-03-19 23:03 ` Matt Benjamin
  2 siblings, 0 replies; 4+ messages in thread
From: liuchang0812 @ 2017-03-17 10:08 UTC (permalink / raw)
  To: ceph-devel

I crated a PR: https://github.com/ceph/ceph/pull/14014

2017-03-17 17:58 GMT+08:00 liuchang0812 <liuchang0812@gmail.com>:
> I saw this problem when i read RGW source code. It seems that that
> `delete` a nullptr will segment fault.
>
> code[1]:
>
> class RGWGetObjLayout : public RGWOp {
>    protected:
>         RGWRados::Object *target{nullptr};
>         RGWObjManifest *manifest{nullptr};
>         rgw_raw_obj head_obj;
>     public:
>          RGWGetObjLayout() {
>              delete target;
>    }
>
>
> [1]. https://github.com/ceph/ceph/blob/master/src/rgw/rgw_op.h#L1777

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why do we delete target in RGWGetObjLayout constructed function?
       [not found] ` <13a064ed-c7b9-c495-ee36-246583eea4e1@redhat.com>
@ 2017-03-17 11:11   ` liuchang0812
  0 siblings, 0 replies; 4+ messages in thread
From: liuchang0812 @ 2017-03-17 11:11 UTC (permalink / raw)
  To: Jos Collin; +Cc: ceph-devel

yes, but target is not deleted.

2017-03-17 18:39 GMT+08:00 Jos Collin <jcollin@redhat.com>:
> No, it won't even if target = 0. As it is unused.
>
>
> On Friday 17 March 2017 03:28 PM, liuchang0812 wrote:
>
> I saw this problem when i read RGW source code. It seems that that
> `delete` a nullptr will segment fault.
>
> code[1]:
>
> class RGWGetObjLayout : public RGWOp {
>    protected:
>         RGWRados::Object *target{nullptr};
>         RGWObjManifest *manifest{nullptr};
>         rgw_raw_obj head_obj;
>     public:
>          RGWGetObjLayout() {
>              delete target;
>    }
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: why do we delete target in RGWGetObjLayout constructed function?
  2017-03-17  9:58 why do we delete target in RGWGetObjLayout constructed function? liuchang0812
  2017-03-17 10:08 ` liuchang0812
       [not found] ` <13a064ed-c7b9-c495-ee36-246583eea4e1@redhat.com>
@ 2017-03-19 23:03 ` Matt Benjamin
  2 siblings, 0 replies; 4+ messages in thread
From: Matt Benjamin @ 2017-03-19 23:03 UTC (permalink / raw)
  To: liuchang0812; +Cc: ceph-devel

Hi,

Something looks funny, I'd agree.  However, for posterity, it's legal and therefore safe to delete (and free) nullptr.

Matt

----- Original Message -----
> From: "liuchang0812" <liuchang0812@gmail.com>
> To: "ceph-devel" <ceph-devel@vger.kernel.org>
> Sent: Friday, March 17, 2017 5:58:14 AM
> Subject: why do we delete target in RGWGetObjLayout constructed function?
> 
> I saw this problem when i read RGW source code. It seems that that
> `delete` a nullptr will segment fault.
> 
> code[1]:
> 
> class RGWGetObjLayout : public RGWOp {
>    protected:
>         RGWRados::Object *target{nullptr};
>         RGWObjManifest *manifest{nullptr};
>         rgw_raw_obj head_obj;
>     public:
>          RGWGetObjLayout() {
>              delete target;
>    }
> 
> 
> [1]. https://github.com/ceph/ceph/blob/master/src/rgw/rgw_op.h#L1777
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Matt Benjamin
Red Hat, Inc.
315 West Huron Street, Suite 140A
Ann Arbor, Michigan 48103

http://www.redhat.com/en/technologies/storage

tel.  734-821-5101
fax.  734-769-8938
cel.  734-216-5309

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-19 23:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17  9:58 why do we delete target in RGWGetObjLayout constructed function? liuchang0812
2017-03-17 10:08 ` liuchang0812
     [not found] ` <13a064ed-c7b9-c495-ee36-246583eea4e1@redhat.com>
2017-03-17 11:11   ` liuchang0812
2017-03-19 23:03 ` Matt Benjamin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.