From patchwork Thu Sep 9 13:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13787 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 60B88BDB1D for ; Thu, 9 Sep 2021 13:18:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA0DB6916C; Thu, 9 Sep 2021 15:18:22 +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="fCdtOC+1"; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 081DB6916B for ; Thu, 9 Sep 2021 15:18:21 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id h3so904651pgb.7 for ; Thu, 09 Sep 2021 06:18:20 -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=TLlkSHByNdK4JdqUsok/vin8/+cUFpQi1ZI4C0GyUwI=; b=fCdtOC+1c3sdPfQbgNRYKABwdbRY8RwhVOsgeYBGgYoqAiS2X38I6m7eGuVZCAdKEX Ad8n18XXj8kANr56DzXtm9sp8y+gBvn69M9KAJczsDYsGdhOSFmLgHQI9Gj5fQ9SPrpv UWSis6U0F0A1517/yLluCNVOF7LvQcjg8jHMkJTM2cV9DQbULmOh//jgqmRhwASg1fFt 11dzIsrLNs2F+s8ul0LqsKzasPOt5+H1VkogqwzIE4lrv1yz2HRY7MP0fqEaBhlbvVvI FbwRYl6oCFGEmPbCQXw9qPuEMHyLs5QPmxiHdQWFmyYyw8zCLCxSqlteYQC2QZS6axl3 yX5Q== 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=TLlkSHByNdK4JdqUsok/vin8/+cUFpQi1ZI4C0GyUwI=; b=AUkOjXpZfkOk6URB97rIQsnfmEdrc67qfNpZg56RlBJTLE6V34cswSqmoV+gC7aI4j SkMETKbYf0CzBwdpXs14/kX4QigpgsZhPLwC+/rX/sYQmq10gce13ODgvSejkceBJOF3 p8aoPNxd2LrxIKPDx7/oLROdg3CUSqP6PIqTVwSL7D2GKlSpLt6D49gOFZSb7/WDiZkw 30O45A5Uxrglb9Fx9Dua8VTQj41G3XOFq/SN/S9fBvBSmx6LgzSLJKYs1re8uqPI3GsT kH3OU+6gk1K7z+lXDpOY5sShRedZtUpkvZgyqTrI0fHVWmN+aT3I7jyAbTYhoG4vLLK+ N3Iw== X-Gm-Message-State: AOAM53351n+uhs4acF1D1Avnz2XGoSIDvA6tNP6Tee7h+BSneMflSUPy kZdk35ZAXxy9buB0mV9u2udzV8IyhC527+QR X-Google-Smtp-Source: ABdhPJwtl4ifDPhRe9hL/XVQ6FrY72J8INLYUCkfpYwLMnPuxN+411EkfOaRBwKMoeIhPg8RwbSoXw== X-Received: by 2002:a63:4d20:: with SMTP id a32mr2654085pgb.247.1631193499201; Thu, 09 Sep 2021 06:18:19 -0700 (PDT) Received: from localhost.localdomain ([1.186.165.215]) by smtp.googlemail.com with ESMTPSA id z131sm2389903pfc.159.2021.09.09.06.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 06:18:18 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Sep 2021 18:48:05 +0530 Message-Id: <20210909131805.38786-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5] 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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp index dbdcaec0b111..4171250584e6 100644 --- a/test/gstreamer/gstreamer_test.cpp +++ b/test/gstreamer/gstreamer_test.cpp @@ -24,6 +24,7 @@ const char *__asan_default_options() } GstreamerTest::GstreamerTest() + : pipeline_(nullptr), libcameraSrc_(nullptr) { /* * GStreamer by default spawns a process to run the @@ -69,12 +70,8 @@ GstreamerTest::GstreamerTest() 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(); }