From patchwork Thu Sep 9 13:07:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13786 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 27CE1BDC71 for ; Thu, 9 Sep 2021 13:08:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AB3216916C; Thu, 9 Sep 2021 15:08:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Yeu0I80D"; dkim-atps=neutral Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A45576916B for ; Thu, 9 Sep 2021 15:08:01 +0200 (CEST) Received: by mail-pg1-x533.google.com with SMTP id s11so1709493pgr.11 for ; Thu, 09 Sep 2021 06:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RNcVsNiuRGfM5U/FE7vLul0fVgxpDRpJHjua7bU+6Qg=; b=Yeu0I80Dl5HGrgBET3nypkZjz/Qs4O9WcboqiK6/NWoUZXvdSxHnN0ejp8rkps9zwg 1MMXlH+TCHl2ld114x5I4SsI2+5h3JBsuJNOjVw8u1LgjYJp1fgMrAiWQ4e5tCsKsu5k jIVBJOOsFneyRiMeRAOV9c2dGIck59sMIZ5ZMoznlQLX/x3SbRDyr79eE5/zvO+jssGc uNNaHWx1GVk+PX1VEuh5HvFPON7oU4FEK0kdIENXUJV4wT1CNnqm7mlOwgEBGjkH5o7P OtibkHwi/rjPPLbLPP8OTtn/Pm3wI7h8mbyyMezUWF0CvDtSC4FjD15+wbYZ94JzTqHs xuyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RNcVsNiuRGfM5U/FE7vLul0fVgxpDRpJHjua7bU+6Qg=; b=ngBIlzOCdczkLNG2XqNkrT6SzjA5/KfJX6BpwJCN2W0thLfZxWAi3dN0mifiie+vvN tRPd1ZuaVsw4zhWimBN50gTngPCfVpHTw+DLUhnthmMlkHzpRVvaYH+pbORElPVuU8Mo QU4UIzJhxWE8L9/d1+O2IbUZ912F+/jkEuCpkWaRe+fDKVkb/rEN6dyhda5Idyn0TTXB TG3WuDt8/F4sD/B1Nf/Snfxuv5aXHLqWGasT7YKUrIbBPtLyKcqDW8rX/M8HpuJZrxJc 9T3dnGaRyNf+Jbm4n2XhOJQ+z+5xSB5sPzX5cF6Fw4s8ykMx425HmbCnlKSq5h3MlTFt 1a9Q== X-Gm-Message-State: AOAM532sEWxMz0Vg0DFfltdQIYdKF+mxO7M0bbFKg8WZQRQTc2SSPgsP ft7D7eEp1Qhg/knfDoSLGzf6aJfFadXGoWOK X-Google-Smtp-Source: ABdhPJwI9BnX/30ziqF+QqeX4YuIxKyGEk/+fJQPOQg2vvvAFKhMUmqoC5cN5EmUhMjCK5dHO/MVWA== X-Received: by 2002:a63:350:: with SMTP id 77mr2590759pgd.441.1631192879546; Thu, 09 Sep 2021 06:07:59 -0700 (PDT) Received: from localhost.localdomain ([1.186.165.215]) by smtp.googlemail.com with ESMTPSA id r2sm2733402pgn.8.2021.09.09.06.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 06:07:59 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Sep 2021 18:37:33 +0530 Message-Id: <20210909130733.25187-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4] test: gstreamer: Fix the destructor of GstreamerTest base class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicolas Dufresne , Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The destructor tried to check if pipeline_ is a parent of libcameraSrc_. This was needed to be checked as if it is, cleanup of libcameraSrc_ would be handled by pipeline itself. Since, the destructor can be called anytime, even when pipeline_ hasn't been created, the use of pipeline_ to check if libcameraSrc_ has an ancestor as pipeline_ caused a segmentation fault. Fixes: f58768092277 ("test: gstreamer: Fix the destructor of GstreamerTest base class") Signed-off-by: Vedant Paranjape Reviewed-by: Jean-Michel Hautbois Reviewed-by: Nicolas Dufresne Reviewed-by: Kieran Bingham --- test/gstreamer/gstreamer_test.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp index dbdcaec0b111..7dcb3c5c2869 100644 --- a/test/gstreamer/gstreamer_test.cpp +++ b/test/gstreamer/gstreamer_test.cpp @@ -64,17 +64,16 @@ GstreamerTest::GstreamerTest() return; } + pipeline_ = nullptr; + libcameraSrc_ = nullptr; + status_ = TestPass; } GstreamerTest::~GstreamerTest() { - if (libcameraSrc_ && - !gst_object_has_as_ancestor(GST_OBJECT(libcameraSrc_), - GST_OBJECT(pipeline_))) - gst_object_unref(libcameraSrc_); - if (pipeline_) - gst_object_unref(pipeline_); + g_clear_object(&pipeline_); + g_clear_object(&libcameraSrc_); gst_deinit(); }