From patchwork Wed Nov 30 00:10:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 17918 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 55983BDE6B for ; Wed, 30 Nov 2022 00:10:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8E2616333F; Wed, 30 Nov 2022 01:10:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669767051; bh=aOd8veRb1Ej8z+GpmUNUWw/89RFGdG6QiSynm8IEMWE=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PsyoZOydJEhAmzUKG4/e0EajI+pIkJwUGllnRByrRIgZTdSOK8vZDzN1wGSObG/m9 9dNKvKhF8DyjHAgDL1kDuWqtlqcm4fqdSS87lHLX52YVLUYheTX8Lf/p4NCKLDvEfn 6Qm4pJ1ydZYlXMmCoOyP2PtcjqtHbNEjRWCnys6uVYIQXoYpDeUSxXuWcPAjdl0oI8 72qgrgjmGrxmxMUut22f5gnOvJW8XFBgeg2FRgE8uLp6pm/eyUWyEL1/1bwTADtCDq EIJ1wVPuqyIt61KdP64eTj2SmDCb+uFogQ5QKaD06PEaf0tkEnLDjveKlYHc8OTEjN zQo9z3gHC4+6w== Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4ADCE63334 for ; Wed, 30 Nov 2022 01:10:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="TrgxXU2K"; dkim-atps=neutral Received: from notapiano.myfiosgateway.com (unknown [IPv6:2600:4041:5b1a:cd00:524d:e95d:1a9c:492a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id 5941666025DF; Wed, 30 Nov 2022 00:10:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669767048; bh=aOd8veRb1Ej8z+GpmUNUWw/89RFGdG6QiSynm8IEMWE=; h=From:To:Cc:Subject:Date:From; b=TrgxXU2KhjvbeB2UMkkAcOHKV83ss32ERXAjFsFgW7cg9nIC0U53R9wk1OJvgq+H4 +Z7BHNf7F8lYxWgLP4gpZlNZnPwxeh434h0MPk7DXRmYq98sW1Ub3s+xpFRr1iNVlm wB50IP0LtfL58VEO/rHGb/A7V8be1I+EUccY8ixyXV6fYKyHqZUwgEcefuO//jDh2d eDD7ZywP7pMBlyFZSy2rExnkYJeA9Uv5EOcfBfagbf7tDgkB17Se/IgKvrHC60BSnt uOB84J+ekI8t92f2/AMG+RspJsuc9OpLNI34d33BUiAldWduKzcQTpHdcjjEo2U1tg xKHWOhn5QEebw== To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 19:10:44 -0500 Message-Id: <20221130001044.651663-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] lc-compliance: Fix segfault on request destruction 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: , X-Patchwork-Original-From: =?utf-8?q?N=C3=ADcolas_F=2E_R=2E_A=2E_Prado_via_libcamera-devel?= From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Reply-To: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Request destructor cancels all associated framebuffers, and therefore assumes they are all still valid. The SimpleCaptureBalanced and SimpleCaptureUnbalanced classes that run the capture sessions on lc-compliance however were freeing the framebuffers before the requests, stored in an automatic variable, were destroyed. This resulted in a segfault when running lc-compliance. Solve the issue by moving the requests vector to the SimpleCapture class and making sure we clear it on stop() before freeing the framebuffers. Signed-off-by: NĂ­colas F. R. A. Prado --- src/apps/lc-compliance/simple_capture.cpp | 8 ++++---- src/apps/lc-compliance/simple_capture.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index ab5cb35c11f2..d02c7b45f180 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -64,6 +64,8 @@ void SimpleCapture::stop() camera_->requestCompleted.disconnect(this); + requests_.clear(); + Stream *stream = config_->at(0).stream(); allocator_->free(stream); } @@ -95,7 +97,6 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests) captureLimit_ = numRequests; /* Queue the recommended number of reqeuests. */ - std::vector> requests; for (const std::unique_ptr &buffer : buffers) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; @@ -104,7 +105,7 @@ void SimpleCaptureBalanced::capture(unsigned int numRequests) ASSERT_EQ(queueRequest(request.get()), 0) << "Failed to queue request"; - requests.push_back(std::move(request)); + requests_.push_back(std::move(request)); } /* Run capture session. */ @@ -156,7 +157,6 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests) captureLimit_ = numRequests; /* Queue the recommended number of reqeuests. */ - std::vector> requests; for (const std::unique_ptr &buffer : buffers) { std::unique_ptr request = camera_->createRequest(); ASSERT_TRUE(request) << "Can't create request"; @@ -165,7 +165,7 @@ void SimpleCaptureUnbalanced::capture(unsigned int numRequests) ASSERT_EQ(camera_->queueRequest(request.get()), 0) << "Failed to queue request"; - requests.push_back(std::move(request)); + requests_.push_back(std::move(request)); } /* Run capture session. */ diff --git a/src/apps/lc-compliance/simple_capture.h b/src/apps/lc-compliance/simple_capture.h index fd9d2a97fd8d..2911d6019923 100644 --- a/src/apps/lc-compliance/simple_capture.h +++ b/src/apps/lc-compliance/simple_capture.h @@ -32,6 +32,7 @@ protected: std::shared_ptr camera_; std::unique_ptr allocator_; std::unique_ptr config_; + std::vector> requests_; }; class SimpleCaptureBalanced : public SimpleCapture