From patchwork Tue Dec 13 09:38:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17992 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 41800C328D for ; Tue, 13 Dec 2022 09:38:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D25D263366; Tue, 13 Dec 2022 10:38:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670924295; bh=tKJs3qRfRLIfF1oBxpnOMmxW/QJT+8A9hcgV/cpmjmE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=w0EAkmY4NgsaJZP3LIPOBaO3E9CvbZ0umdV1A5Mt0R4gL5KdOWYpGGLK6arBi4JeW x68ODYnvHTh6yyvRjHjIUlb5GmmRCvA0aEyzp1cWZUC+EzgLbBhaGkMnMOH5mDA7xX oY6gSunN0I5pj7htt2MMsXWG/eCVY1F4BA1Kpw+2kztxC1HH0MhvIR+Kzs/88wqe46 3mmyy1GHP5BrV1dw/6TidM6R5iHHfRjw2tytu060K5qqnvGmygQ3RbUcgtGqJoaU6y Essk1ALxvnPx/7p7ZNL1XME04whipRj0wiBULDq5nFuerv7vEz9Mju6jiRILABNm/G chvEMIUv3+x7A== 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 1A8FB6334D for ; Tue, 13 Dec 2022 10:38:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ePdYVyB5"; 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 ED5BF4A7; Tue, 13 Dec 2022 10:38:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670924293; bh=tKJs3qRfRLIfF1oBxpnOMmxW/QJT+8A9hcgV/cpmjmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePdYVyB5TSXMXyLtceeCPj0K5BQiZ55tRAfCDFPmHXKnXMaYdfWQrIo6wg78aCs2B 07JIn4WQvCphiHo1fNiXwtaAhCnVMKo0YUhWNeytH4au3xRnMMkPLj8r1lC8XGUF0t tNrZTSrIJdplpH4uKD15F0P52gbUbwJ6nvnM9hpY= To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Dec 2022 18:38:00 +0900 Message-Id: <20221213093802.704177-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221213093802.704177-1-paul.elder@ideasonboard.com> References: <20221213093802.704177-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] lc-compliance: simple_capture: Fix Request reuse 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 balanced simple capture test, in the request completion handler, the Request is marked for reuse *before* checking (based on the queueCount_) if it should actually be queued to the Camera. This causes the last Request to end up being marked for reuse and then *not* get queued to the Camera. The consequence of this is that a buffer is assigned to the Request, so that it must be canceled when the Request is destroyed. Additionally, since the Request was not queued to the Camera, it doesn't get completed at all by the Camera. Thus the buffer is deallocated by SimpleCapture::stop(), and after SimpleCaptureBalanced::capture() exits, the Request is destroyed and tries to cancel the deallocated buffer, causing the segfault. Fix this by reordering marking the Request for reuse so that it happens if and only if the Request wil be queued to the Camera. Fixes: https://bugs.libcamera.org/show_bug.cgi?id=171 Signed-off-by: Paul Elder --- src/apps/lc-compliance/simple_capture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index cf4d7cf3..4a05b919 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -122,6 +122,7 @@ int SimpleCaptureBalanced::queueRequest(Request *request) if (queueCount_ > captureLimit_) return 0; + request->reuse(Request::ReuseBuffers); return camera_->queueRequest(request); } @@ -133,7 +134,6 @@ void SimpleCaptureBalanced::requestComplete(Request *request) return; } - request->reuse(Request::ReuseBuffers); if (queueRequest(request)) loop_->exit(-EINVAL); }