From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2Iti-00063y-N1 for qemu-devel@nongnu.org; Wed, 02 Jul 2014 07:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2Itc-0006Nw-I7 for qemu-devel@nongnu.org; Wed, 02 Jul 2014 07:40:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2Itc-0006Nk-8e for qemu-devel@nongnu.org; Wed, 02 Jul 2014 07:40:16 -0400 Message-ID: <53B3EF92.2020406@redhat.com> Date: Wed, 02 Jul 2014 13:40:02 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1404291017-7456-1-git-send-email-arei.gonglei@huawei.com> <53B3CB04.5040909@redhat.com> <53B3CFB8.5000800@huawei.com> <53B3D011.9000200@redhat.com> <33183CC9F5247A488A2544077AF1902086C18093@SZXEMA503-MBS.china.huawei.com> <53B3DBFD.1090009@redhat.com> <53B3EDFF.6010309@huawei.com> In-Reply-To: <53B3EDFF.6010309@huawei.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] ide: fix double free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ChenLiang Cc: "kwolf@redhat.com" , "Gonglei (Arei)" , "Huangweidong (C)" , "qemu-devel@nongnu.org" , "stefanha@redhat.com" Il 02/07/2014 13:33, ChenLiang ha scritto: > On 2014/7/2 18:16, Paolo Bonzini wrote: > >> Il 02/07/2014 11:46, Gonglei (Arei) ha scritto: >>> Hi, Paolo. We have tested your above patch, and it works well for us. >> >> I'm still not sure where the fix is. I jotted the patch quickly, but I'd rather understand it better before submitting it. Here is it again: >> >> --- a/dma-helpers.c >> +++ b/dma-helpers.c >> @@ -181,15 +181,15 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb) >> trace_dma_aio_cancel(dbs); >> >> + dbs->in_cancel = true; >> if (dbs->acb) { >> BlockDriverAIOCB *acb = dbs->acb; >> dbs->acb = NULL; >> - dbs->in_cancel = true; >> bdrv_aio_cancel(acb); >> - dbs->in_cancel = false; >> } >> dbs->common.cb = NULL; >> dma_complete(dbs, 0); >> + qemu_aio_release(dbs); >> } >> > > > Hmm, dbs->in_cancel will be true always. Although this will avoid freeing dbs by dma_comlete. > But it maybe a mistake. This was on purpose; I'm doing the free myself in dma_aio_cancel, so I wanted to avoid the qemu_aio_release from dma_complete. This was in case of a recursive call to dma_complete. But I don't see how that recursive call could happen outside the "if (dbs->acb)"; and inside the "if" the protection is there already. Can you gather the backtraces for _both_ calls to qemu_aio_release, rather than just the second? With what guest are you encountering the bug? Paolo