[Gluster-devel] crypt xlator bug

Raghavendra Bhat rabhat at redhat.com
Thu Apr 2 13:57:23 UTC 2015


On Thursday 02 April 2015 05:50 PM, Jeff Darcy wrote:
>> I think, crypt xlator should do a mem_put of local after doing STACK_UNWIND
>> like other xlators which also use mem_get for local (such as AFR). I am
>> suspecting crypt not doing mem_put might be the reason for the bug
>> mentioned.
> My understanding was that mem_put should be called automatically from
> FRAME_DESTROY, which is itself called from STACK_DESTROY when the fop
> completes (e.g. at FUSE or GFAPI).  On the other hand, I see that AFR
> and others call mem_put themselves, without zeroing the local pointer.
> In my (possibly no longer relevant) experience, freeing local myself
> without zeroing the pointer would lead to a double free, and I don't
> see why that's not the case here.  What am I missing?

As per my understanding, the xlators which get local by mem_get should 
be doing below things in callback funtion  just before unwinding:

1) save frame->local pointer (i.e. local = frame->local);
2) STACK_UNWIND
3) mem_put (local)

After STACK_UNWIND and before mem_put any reference to fd or inode or 
dict that might be present in the local should be unrefed (also any 
allocated resources that are present in local should be freed). So 
mem_put is done at last. To avoid double free in FRAME_DESTROY, 
frame->local is set to NULL before doing STACK_UNWIND.

I suspect not doing 1 of the above three operations (may be either 1st 
or 3rd) in crypt xlator might be the reason for the bug.

Regards,
Raghavendra Bhat

> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://www.gluster.org/mailman/listinfo/gluster-devel



More information about the Gluster-devel mailing list