[{"id":35082,"web_url":"https://patchwork.libcamera.org/comment/35082/","msgid":"<175334605019.774292.13624874390588458361@neptunite.rasen.tech>","date":"2025-07-24T08:34:10","subject":"Re: [PATCH v2] utils: codegen: ipc: Check `ipc_` instead of\n\t`isolate_`","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Barnabás,\n\nQuoting Barnabás Pőcze (2025-07-22 23:53:34)\n> Only try to send the \"Exit\" message if the `ipc_` pointer is non-null. If\n> the constructor fails, then `ipc_` might remain nullptr, which would lead\n> to a nullptr dereference in the destructor.\n> \n> This change also modifies the constructor so that only a valid `IPCPipeUnixSocket`\n> object will be saved into the `ipc_` member, which avoids error messages when\n> `IPCPipeUnixSocket::sendAsync()` is called in the inappropriate state in the\n> destructor.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=276\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n> changes in v2:\n>   * modify constructor not to save \"invalid\" IPCPipeUnixSocket into member\n> \n> v1: https://patchwork.libcamera.org/patch/23894/\n> ---\n>  .../libcamera_templates/module_ipa_proxy.cpp.tmpl     | 11 ++++++-----\n>  1 file changed, 6 insertions(+), 5 deletions(-)\n> \n> diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> index 0f87e7976..18b4ab5e5 100644\n> --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> @@ -61,15 +61,16 @@ namespace {{ns}} {\n>                         return;\n>                 }\n> \n> -               ipc_ = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n> -                                                          proxyWorkerPath.c_str());\n> -               if (!ipc_->isConnected()) {\n> +               auto ipc = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n> +                                                              proxyWorkerPath.c_str());\n> +               if (!ipc->isConnected()) {\n>                         LOG(IPAProxy, Error) << \"Failed to create IPCPipe\";\n>                         return;\n>                 }\n> \n> -               ipc_->recv.connect(this, &{{proxy_name}}::recvMessage);\n> +               ipc->recv.connect(this, &{{proxy_name}}::recvMessage);\n> \n> +               ipc_ = std::move(ipc);\n\nOh, nice.\n\n>                 valid_ = true;\n>                 return;\n>         }\n> @@ -96,7 +97,7 @@ namespace {{ns}} {\n> \n>  {{proxy_name}}::~{{proxy_name}}()\n>  {\n> -       if (isolate_) {\n> +       if (ipc_) {\n\nOh ok I see it now.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n>                 IPCMessage::Header header =\n>                         { static_cast<uint32_t>({{cmd_enum_name}}::Exit), seq_++ };\n>                 IPCMessage msg(header);\n> --\n> 2.50.1","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 C1D10C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Jul 2025 08:34:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CD907690B9;\n\tThu, 24 Jul 2025 10:34:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 448AF69098\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jul 2025 10:34:16 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:be7f:7fca:78b4:1343])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id CB329C70;\n\tThu, 24 Jul 2025 10:33:36 +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=\"hTuj9t09\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753346017;\n\tbh=I2AX7+60BKTfLC7lNa4is/Xv8GKMkzBdBkE12z9uHgM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=hTuj9t094w37V1oQs1rfI7sDu9cWfXGAUXoetKkfQy/uhOdXg5SXh0nvu+qS41m6D\n\tZ8ZXYc+FYvQuKZmT2t1xctPk3k3KRiVGS910BkXcneRk/+aZb78fAyVgMJTvbMXp0V\n\t8j/Se1buYQtccrOS1VJDJtPS89JPSAgvyITLTKNw=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","References":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v2] utils: codegen: ipc: Check `ipc_` instead of\n\t`isolate_`","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 24 Jul 2025 17:34:10 +0900","Message-ID":"<175334605019.774292.13624874390588458361@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}},{"id":35086,"web_url":"https://patchwork.libcamera.org/comment/35086/","msgid":"<175334751516.560048.8244940197749327798@ping.linuxembedded.co.uk>","date":"2025-07-24T08:58:35","subject":"Re: [PATCH v2] utils: codegen: ipc: Check `ipc_` instead of\n\t`isolate_`","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-07-22 15:53:34)\n> Only try to send the \"Exit\" message if the `ipc_` pointer is non-null. If\n> the constructor fails, then `ipc_` might remain nullptr, which would lead\n> to a nullptr dereference in the destructor.\n> \n> This change also modifies the constructor so that only a valid `IPCPipeUnixSocket`\n> object will be saved into the `ipc_` member, which avoids error messages when\n> `IPCPipeUnixSocket::sendAsync()` is called in the inappropriate state in the\n> destructor.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=276\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n> changes in v2:\n>   * modify constructor not to save \"invalid\" IPCPipeUnixSocket into member\n> \n> v1: https://patchwork.libcamera.org/patch/23894/\n> ---\n>  .../libcamera_templates/module_ipa_proxy.cpp.tmpl     | 11 ++++++-----\n>  1 file changed, 6 insertions(+), 5 deletions(-)\n> \n> diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> index 0f87e7976..18b4ab5e5 100644\n> --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl\n> @@ -61,15 +61,16 @@ namespace {{ns}} {\n>                         return;\n>                 }\n> \n> -               ipc_ = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n> -                                                          proxyWorkerPath.c_str());\n> -               if (!ipc_->isConnected()) {\n> +               auto ipc = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n> +                                                              proxyWorkerPath.c_str());\n> +               if (!ipc->isConnected()) {\n>                         LOG(IPAProxy, Error) << \"Failed to create IPCPipe\";\n>                         return;\n>                 }\n> \n> -               ipc_->recv.connect(this, &{{proxy_name}}::recvMessage);\n> +               ipc->recv.connect(this, &{{proxy_name}}::recvMessage);\n> \n> +               ipc_ = std::move(ipc);\n>                 valid_ = true;\n>                 return;\n>         }\n> @@ -96,7 +97,7 @@ namespace {{ns}} {\n> \n>  {{proxy_name}}::~{{proxy_name}}()\n>  {\n> -       if (isolate_) {\n> +       if (ipc_) {\n>                 IPCMessage::Header header =\n>                         { static_cast<uint32_t>({{cmd_enum_name}}::Exit), seq_++ };\n>                 IPCMessage msg(header);\n> --\n> 2.50.1","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 C559ABDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Jul 2025 08:58:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BC6BA690C4;\n\tThu, 24 Jul 2025 10:58:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E0DC690BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jul 2025 10:58:38 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3065BC78;\n\tThu, 24 Jul 2025 10:57:59 +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=\"W/xT9kcO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753347479;\n\tbh=vb7LyHvXPsc6RvW92w421NIZGA9JHXwnT14XgrS2RYg=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=W/xT9kcORe5yDdQ9r6f2j2QlDTfkFCzrpFzciPLlEG0mWZjn6I3eDpeZAibF7o8Ku\n\tHr4icx7QqjLM0IWz+1M0D+kIkRCPy2aqGpxCdV3x5Dlyls+FMT7YWfFfe6/4Cm8rEK\n\tBixMcOzj3UUqw24HmeRoKy3+QdqZWCdlr2gc5HZk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","References":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v2] utils: codegen: ipc: Check `ipc_` instead of\n\t`isolate_`","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 24 Jul 2025 09:58:35 +0100","Message-ID":"<175334751516.560048.8244940197749327798@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]