[{"id":19587,"web_url":"https://patchwork.libcamera.org/comment/19587/","msgid":"<5e8fcbc30b92513fac95faa83958d1620abfd916.camel@collabora.com>","date":"2021-09-09T16:28:38","subject":"Re: [libcamera-devel] [PATCH v5] test: gstreamer: Fix the\n\tdestructor of GstreamerTest base class","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Le jeudi 09 septembre 2021 à 18:48 +0530, Vedant Paranjape a écrit :\n> The destructor tried to check if pipeline_ is a parent of libcameraSrc_.\n> This was needed to be checked as if it is, cleanup of libcameraSrc_\n> would be handled by pipeline itself.\n> \n> Since, the destructor can be called anytime, even when pipeline_ hasn't\n> been created, the use of pipeline_ to check if libcameraSrc_ has an\n> ancestor as pipeline_ caused a segmentation fault.\n> \n> Fixes: f58768092277 (\"test: gstreamer: Fix the destructor of GstreamerTest base class\")\n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  test/gstreamer/gstreamer_test.cpp | 9 +++------\n>  1 file changed, 3 insertions(+), 6 deletions(-)\n> \n> diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp\n> index dbdcaec0b111..4171250584e6 100644\n> --- a/test/gstreamer/gstreamer_test.cpp\n> +++ b/test/gstreamer/gstreamer_test.cpp\n> @@ -24,6 +24,7 @@ const char *__asan_default_options()\n>  }\n>  \n>  GstreamerTest::GstreamerTest()\n> +\t: pipeline_(nullptr), libcameraSrc_(nullptr)\n\nGood catch, you already got my R-b.\n\n>  {\n>  \t/*\n>  \t* GStreamer by default spawns a process to run the\n> @@ -69,12 +70,8 @@ GstreamerTest::GstreamerTest()\n>  \n>  GstreamerTest::~GstreamerTest()\n>  {\n> -\tif (libcameraSrc_ &&\n> -\t    !gst_object_has_as_ancestor(GST_OBJECT(libcameraSrc_),\n> -\t\t\t\t\tGST_OBJECT(pipeline_)))\n> -\t\tgst_object_unref(libcameraSrc_);\n> -\tif (pipeline_)\n> -\t\tgst_object_unref(pipeline_);\n> +\tg_clear_object(&pipeline_);\n> +\tg_clear_object(&libcameraSrc_);\n>  \n>  \tgst_deinit();\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 6F181BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Sep 2021 16:28:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 068776916E;\n\tThu,  9 Sep 2021 18:28:52 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 993A06916B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Sep 2021 18:28:50 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nicolas) with ESMTPSA id 6806A1F40875"],"Message-ID":"<5e8fcbc30b92513fac95faa83958d1620abfd916.camel@collabora.com>","From":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 09 Sep 2021 12:28:38 -0400","In-Reply-To":"<20210909131805.38786-1-vedantparanjape160201@gmail.com>","References":"<20210909131805.38786-1-vedantparanjape160201@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.40.4 (3.40.4-1.fc34) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v5] test: gstreamer: Fix the\n\tdestructor of GstreamerTest base class","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>"}}]