{"id":23900,"url":"https://patchwork.libcamera.org/api/patches/23900/?format=json","web_url":"https://patchwork.libcamera.org/patch/23900/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","date":"2025-07-22T14:53:34","name":"[v2] utils: codegen: ipc: Check `ipc_` instead of `isolate_`","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"90b37ec96116dedd7671a3a64af72b5d0995e3c1","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23900/mbox/","series":[{"id":5312,"url":"https://patchwork.libcamera.org/api/series/5312/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5312","date":"2025-07-22T14:53:34","name":"[v2] utils: codegen: ipc: Check `ipc_` instead of `isolate_`","version":2,"mbox":"https://patchwork.libcamera.org/series/5312/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23900/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23900/checks/","tags":{},"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 24B28BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Jul 2025 14:53:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8C8A6903C;\n\tTue, 22 Jul 2025 16:53:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4176E68F93\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jul 2025 16:53:37 +0200 (CEST)","from pb-laptop.local (185.221.140.39.nat.pool.zt.hu\n\t[185.221.140.39])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 89CEE19DC;\n\tTue, 22 Jul 2025 16:52: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=\"QSHHyybT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753195979;\n\tbh=ka+3NVoW1Of/ToelkarOWzft0TkgNeA0lqFRKM1bhlY=;\n\th=From:To:Subject:Date:From;\n\tb=QSHHyybTTX7QOXtmfvM1OvwjViRU96qGbhIYnTVk5LjAArEjz8N8cw4kHFqLaaKlr\n\tpmIjxnaG8OXIuGbClSdJMPM8ZUOO8QdkcVpgTeNCnqqp+J/NMg9GORLgKLakFVcZlQ\n\t5v/+Vhjm6hOARYlcqn19qzFX8mXX2Fmo0zo38vt0=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH v2] utils: codegen: ipc: Check `ipc_` instead of `isolate_`","Date":"Tue, 22 Jul 2025 16:53:34 +0200","Message-ID":"<20250722145334.1777305-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.50.1","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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>"},"content":"Only try to send the \"Exit\" message if the `ipc_` pointer is non-null. If\nthe constructor fails, then `ipc_` might remain nullptr, which would lead\nto a nullptr dereference in the destructor.\n\nThis change also modifies the constructor so that only a valid `IPCPipeUnixSocket`\nobject will be saved into the `ipc_` member, which avoids error messages when\n`IPCPipeUnixSocket::sendAsync()` is called in the inappropriate state in the\ndestructor.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=276\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nchanges in v2:\n  * modify constructor not to save \"invalid\" IPCPipeUnixSocket into member\n\nv1: 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--\n2.50.1","diff":"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\nindex 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 \t\t\treturn;\n \t\t}\n\n-\t\tipc_ = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n-\t\t\t\t\t\t\t   proxyWorkerPath.c_str());\n-\t\tif (!ipc_->isConnected()) {\n+\t\tauto ipc = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),\n+\t\t\t\t\t\t\t       proxyWorkerPath.c_str());\n+\t\tif (!ipc->isConnected()) {\n \t\t\tLOG(IPAProxy, Error) << \"Failed to create IPCPipe\";\n \t\t\treturn;\n \t\t}\n\n-\t\tipc_->recv.connect(this, &{{proxy_name}}::recvMessage);\n+\t\tipc->recv.connect(this, &{{proxy_name}}::recvMessage);\n\n+\t\tipc_ = std::move(ipc);\n \t\tvalid_ = true;\n \t\treturn;\n \t}\n@@ -96,7 +97,7 @@ namespace {{ns}} {\n\n {{proxy_name}}::~{{proxy_name}}()\n {\n-\tif (isolate_) {\n+\tif (ipc_) {\n \t\tIPCMessage::Header header =\n \t\t\t{ static_cast<uint32_t>({{cmd_enum_name}}::Exit), seq_++ };\n \t\tIPCMessage msg(header);\n","prefixes":["v2"]}