[{"id":19531,"web_url":"https://patchwork.libcamera.org/comment/19531/","msgid":"<CAO5uPHNfrvY8cBSduczUtk7CQW6vUvRoET-3HNMsYzrXfRRNYw@mail.gmail.com>","date":"2021-09-08T07:36:02","subject":"Re: [libcamera-devel] [v2 PATCH] android: mm: cros_camera_buffer:\n\tLog failure error on cleanup","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Umang, thank you for the patch.\n\nOn Tue, Sep 7, 2021 at 11:59 PM Umang Jain <umang.jain@ideasonboard.com> wrote:\n>\n> Failure can still happen by CameraBufferManager during Unlock() and/or\n> Deregister() of camera3Buffer handles. We should be logging those\n> errors as well.\n>\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n> Changes in v2:\n> - Remove a debug log that creeped in by mistake\n>\n> I have been able to spot one of the failure which is happening on my\n> in-developement async post-processing. It is due a failure in\n> Deregister(). It is intermittent and non-fatal as far as I can see.\n>\n> Having a failure log in HAL, apart from https://paste.debian.net/1210728/\n> helps to know the exact place from where the error is originating from\n> libcamera HAL.\n> ---\n>  src/android/mm/cros_camera_buffer.cpp | 18 ++++++++++++++----\n>  1 file changed, 14 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp\n> index ec45e04c..86770135 100644\n> --- a/src/android/mm/cros_camera_buffer.cpp\n> +++ b/src/android/mm/cros_camera_buffer.cpp\n> @@ -73,10 +73,20 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer,\n>\n>  CameraBuffer::Private::~Private()\n>  {\n> -       if (mapped_)\n> -               bufferManager_->Unlock(handle_);\n> -       if (registered_)\n> -               bufferManager_->Deregister(handle_);\n> +       int ret;\n> +       if (mapped_) {\n> +               ret = bufferManager_->Unlock(handle_);\n> +               if (ret != 0)\n> +                       LOG(HAL, Error) << \"Failed to unlock buffer: \"\n> +                                       << strerror(-ret);\n> +       }\n> +\n> +       if (registered_) {\n> +               ret = bufferManager_->Deregister(handle_);\n> +               if (ret != 0)\n> +                       LOG(HAL, Error) << \"Failed to deregister buffer: \"\n> +                                       << strerror(-ret);\n> +       }\n>  }\n>\n>  unsigned int CameraBuffer::Private::numPlanes() const\n> --\n> 2.31.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2E3C8BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Sep 2021 07:36:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DCFFA6916E;\n\tWed,  8 Sep 2021 09:36:14 +0200 (CEST)","from mail-ej1-x636.google.com (mail-ej1-x636.google.com\n\t[IPv6:2a00:1450:4864:20::636])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE7566024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Sep 2021 09:36:13 +0200 (CEST)","by mail-ej1-x636.google.com with SMTP id e21so2244759ejz.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Sep 2021 00:36:13 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"LeS6WOoD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=vZquSVbp+bAPM8sje8aQcDKCE3XxbGILYMUsqaGrraU=;\n\tb=LeS6WOoDXP9Qikg7befPP4HM3KcKuCcM4RNuSerkPhFgGZKbvYzy9I03HCbXwcgA7O\n\tsvMqGONZUEDbS5gMJkcR2ASzBhSyaRASNYnwQiJjj+y6Q4o8QdvBnyZNv59e6U17Sq5N\n\tsoUbpSGw6EROJbxrO3Cw5rmUO404rB6LCQyDw=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=vZquSVbp+bAPM8sje8aQcDKCE3XxbGILYMUsqaGrraU=;\n\tb=IwWwJCxUwkJrsXnBQp22UXdxQuLviXsLP7045SymbuOLYDeAUTaPBxgbGrI7I668YA\n\tZ6cKXszQbqm1fBewYjz0602cNiaAes2tZyMG35XuUoqSkZpvJWBdpupwyKbQBKdzJDqc\n\t8EBXIz+mnZAGVA1KhummJC9cIKz1GknJsxMFITCJAJl0Gk99ZyAlIQHF8RoVhZfxBnyY\n\taN7R398z3KX53RaDBrdSdr2qzR6NkkLryuglKbedJ7bnFy2bRRWXgUKEX7L9ZqPfL15m\n\tRP8CwjbZ1snLDUNxxpq2kIQVUPI1U0loe3cUU0GxgiY7IOpgOV70sCU1Wo0dpDyXRptF\n\tlriA==","X-Gm-Message-State":"AOAM530oVgz6auX++SrEIG2Ly9cPQlwnhZYa8ZcYCOcVOHTYx/n5YEbS\n\tyb9lqISlpVJh/8gxBCpYEhk9exBNiP+QP5VbhbCmdQ==","X-Google-Smtp-Source":"ABdhPJwbdeuHGxS7fYAU4mVy4H3xJA0/43NepUqXNblMFfiuD0BNW8iy+xaDcxJ7ABVWuIAiGFYMqLiUfUJAeetVDf8=","X-Received":"by 2002:a17:906:3146:: with SMTP id\n\te6mr2618842eje.296.1631086573337; \n\tWed, 08 Sep 2021 00:36:13 -0700 (PDT)","MIME-Version":"1.0","References":"<20210907145949.270824-1-umang.jain@ideasonboard.com>","In-Reply-To":"<20210907145949.270824-1-umang.jain@ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Wed, 8 Sep 2021 16:36:02 +0900","Message-ID":"<CAO5uPHNfrvY8cBSduczUtk7CQW6vUvRoET-3HNMsYzrXfRRNYw@mail.gmail.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [v2 PATCH] android: mm: cros_camera_buffer:\n\tLog failure error on cleanup","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19551,"web_url":"https://patchwork.libcamera.org/comment/19551/","msgid":"<25626e2a-97d9-6f6b-7ebe-777371958a2c@ideasonboard.com>","date":"2021-09-08T13:19:02","subject":"Re: [libcamera-devel] [v2 PATCH] android: mm: cros_camera_buffer:\n\tLog failure error on cleanup","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 07/09/2021 15:59, Umang Jain wrote:\n> Failure can still happen by CameraBufferManager during Unlock() and/or\n> Deregister() of camera3Buffer handles. We should be logging those\n> errors as well.\n> \n\nI am suspicious that the reason you've seen these errors is that you are\ndouble-free'ing the CameraBuffer (which is why you get an invalid handle).\n\nI think having the error prints are better than not having them though,\nas it should there was a failure that was otherwise silent.\n\nI'm surprised there wasn't a segfault or such in fact.\n\nBut there's no direct issue or fault with this patch - It makes me go\nback to wanting to put a double-free protection/assertion on the\nExtensible class though..\n\nBut for here:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n> Changes in v2:\n> - Remove a debug log that creeped in by mistake\n> \n> I have been able to spot one of the failure which is happening on my\n> in-developement async post-processing. It is due a failure in\n> Deregister(). It is intermittent and non-fatal as far as I can see.\n> \n> Having a failure log in HAL, apart from https://paste.debian.net/1210728/\n> helps to know the exact place from where the error is originating from\n> libcamera HAL.\n> ---\n>  src/android/mm/cros_camera_buffer.cpp | 18 ++++++++++++++----\n>  1 file changed, 14 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp\n> index ec45e04c..86770135 100644\n> --- a/src/android/mm/cros_camera_buffer.cpp\n> +++ b/src/android/mm/cros_camera_buffer.cpp\n> @@ -73,10 +73,20 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer,\n>  \n>  CameraBuffer::Private::~Private()\n>  {\n> -\tif (mapped_)\n> -\t\tbufferManager_->Unlock(handle_);\n> -\tif (registered_)\n> -\t\tbufferManager_->Deregister(handle_);\n> +\tint ret;\n> +\tif (mapped_) {\n> +\t\tret = bufferManager_->Unlock(handle_);\n> +\t\tif (ret != 0)\n> +\t\t\tLOG(HAL, Error) << \"Failed to unlock buffer: \"\n> +\t\t\t\t\t<< strerror(-ret);\n> +\t}\n> +\n> +\tif (registered_) {\n> +\t\tret = bufferManager_->Deregister(handle_);\n> +\t\tif (ret != 0)\n> +\t\t\tLOG(HAL, Error) << \"Failed to deregister buffer: \"\n> +\t\t\t\t\t<< strerror(-ret);\n> +\t}\n>  }\n>  \n>  unsigned int CameraBuffer::Private::numPlanes() const\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8E45DBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Sep 2021 13:19:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E17D6916E;\n\tWed,  8 Sep 2021 15:19:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D1C160503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Sep 2021 15:19:05 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CA7C8993;\n\tWed,  8 Sep 2021 15:19:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"B1GBSCMh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631107144;\n\tbh=ONlb5yjE4Sek0R4wA9TkvZ7Xb20xbbbyHSyCVJXg1vo=;\n\th=To:References:From:Subject:Date:In-Reply-To:From;\n\tb=B1GBSCMhGGjdvkWraLhFhe7VuZuv8nLz+NAUFQ64Os0nSruN3h9SAb737FeobpGvE\n\tEIZAdTz1djhn8kUGnwRP6WXBgG/H9LEHRMJLRp8if45URb0KL5B3ckGd966QzVkIw6\n\t1grGed22EuvOYkCmTGvvdNBzCWYZXZjHdSiF9Wj4=","To":"Umang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210907145949.270824-1-umang.jain@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<25626e2a-97d9-6f6b-7ebe-777371958a2c@ideasonboard.com>","Date":"Wed, 8 Sep 2021 14:19:02 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210907145949.270824-1-umang.jain@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [v2 PATCH] android: mm: cros_camera_buffer:\n\tLog failure error on cleanup","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]