From patchwork Tue Nov 29 11:00:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17906 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 20185BDE6B for ; Tue, 29 Nov 2022 11:00:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B5F3063336; Tue, 29 Nov 2022 12:00:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669719616; bh=5niDgTJp4J4JtWGifODW809S015pFpzOxYdN0BE7/g8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lW7aJvWcCq+U49KeMSCStx5IrqPTLpZ2jreWCZ5WWzTLSV0yzDbZ0FYg2UTalkl6v CfmFg52xqIE/djaprKXhMLmp5t5lM0XKEXziWfyU8iy4CSetNnxIHKjjDs7WMffdIL bCKo3D5s20Q0PpjUuo6VxlkzojM4oHr17RLmNxsWdnHKCIo1IXT1bVjW82RNIcFyul LUwVNP8bQANQfJ5vr1KYyvGSCnY9xOo3EeFXoKXNuH60lNn7WRorMw/7DtrnBjIV3E tA/XS8JwGktuGrVB0oEgM6B8+qjwXvFqFJgPcaqF7rxDWQddCQZlxyAKwDNKONjVJN JdwEUztCmNdwA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E48161F24 for ; Tue, 29 Nov 2022 12:00:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="b6ulLA48"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 31BA44DA; Tue, 29 Nov 2022 12:00:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669719615; bh=5niDgTJp4J4JtWGifODW809S015pFpzOxYdN0BE7/g8=; h=From:To:Cc:Subject:Date:From; b=b6ulLA48UPFBKpRxx2xhQ506aZcgHwEIMaylSdOtbDMnt8xZ26fnFq9Q+kReId7A9 PSbvLEp8W+L3+5Bju1y7041cppg739dWSbDRB5saHGQXQRdJuRKDwEtRx4Yod9JV/V NlSXlqiHzSH7pjiS9ZKaMyG38Vprs+C7kBIsctt8= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 20:00:05 +0900 Message-Id: <20221129110005.4067748-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] lc-compliance: simple_capture: Free Requests properly 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In the simple capture tests, in the capture functions, the Requests were auto-deallocated by the function going out of scope after the test completed. However, before the end of the scope, the Framebuffers that the Requests referred to were manually freed. Thus when the Requests were deallocated, they tried to cancel their Framebuffers, which involve setting the status to cancelled, which obviously causes a segfault because the Framebuffers had already been freed. Fix this by moving the list of Requests to a member variable and deallocating them before deallocating the Framebuffers at stop() time. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Tested-by: Kieran Bingham Reviewed-by: NĂ­colas F. R. A. Prado Tested-by: NĂ­colas F. R. A. Prado --- src/apps/lc-compliance/simple_capture.cpp | 7 +++---- src/apps/lc-compliance/simple_capture.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index ab5cb35c..cf4d7cf3 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -65,6 +65,7 @@ void SimpleCapture::stop() camera_->requestCompleted.disconnect(this); Stream *stream = config_->at(0).stream(); + requests_.clear(); allocator_->free(stream); } @@ -95,7 +96,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 +104,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 +156,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 +164,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 fd9d2a97..2911d601 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