{"id":17992,"url":"https://patchwork.libcamera.org/api/patches/17992/?format=json","web_url":"https://patchwork.libcamera.org/patch/17992/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221213093802.704177-2-paul.elder@ideasonboard.com>","date":"2022-12-13T09:38:00","name":"[libcamera-devel,1/3] lc-compliance: simple_capture: Fix Request reuse","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0b482cbbf61cc724e82034c8397e9619cf1d5a8f","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17992/mbox/","series":[{"id":3669,"url":"https://patchwork.libcamera.org/api/series/3669/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3669","date":"2022-12-13T09:37:59","name":"lc-compliance: Fix SimpleCapture test","version":1,"mbox":"https://patchwork.libcamera.org/series/3669/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17992/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17992/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 41800C328D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Dec 2022 09:38:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D25D263366;\n\tTue, 13 Dec 2022 10:38:15 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A8FB6334D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Dec 2022 10:38:14 +0100 (CET)","from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ED5BF4A7;\n\tTue, 13 Dec 2022 10:38:12 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670924295;\n\tbh=tKJs3qRfRLIfF1oBxpnOMmxW/QJT+8A9hcgV/cpmjmE=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=w0EAkmY4NgsaJZP3LIPOBaO3E9CvbZ0umdV1A5Mt0R4gL5KdOWYpGGLK6arBi4JeW\n\tx68ODYnvHTh6yyvRjHjIUlb5GmmRCvA0aEyzp1cWZUC+EzgLbBhaGkMnMOH5mDA7xX\n\toY6gSunN0I5pj7htt2MMsXWG/eCVY1F4BA1Kpw+2kztxC1HH0MhvIR+Kzs/88wqe46\n\t3mmyy1GHP5BrV1dw/6TidM6R5iHHfRjw2tytu060K5qqnvGmygQ3RbUcgtGqJoaU6y\n\tEssk1ALxvnPx/7p7ZNL1XME04whipRj0wiBULDq5nFuerv7vEz9Mju6jiRILABNm/G\n\tchvEMIUv3+x7A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1670924293;\n\tbh=tKJs3qRfRLIfF1oBxpnOMmxW/QJT+8A9hcgV/cpmjmE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ePdYVyB5TSXMXyLtceeCPj0K5BQiZ55tRAfCDFPmHXKnXMaYdfWQrIo6wg78aCs2B\n\t07JIn4WQvCphiHo1fNiXwtaAhCnVMKo0YUhWNeytH4au3xRnMMkPLj8r1lC8XGUF0t\n\ttNrZTSrIJdplpH4uKD15F0P52gbUbwJ6nvnM9hpY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ePdYVyB5\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/3] lc-compliance: simple_capture: Fix\n\tRequest reuse","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"In the balanced simple capture test, in the request completion handler,\nthe Request is marked for reuse *before* checking (based on the\nqueueCount_) if it should actually be queued to the Camera. This causes\nthe last Request to end up being marked for reuse and then *not* get\nqueued to the Camera.\n\nThe consequence of this is that a buffer is assigned to the Request, so\nthat it must be canceled when the Request is destroyed. Additionally,\nsince the Request was not queued to the Camera, it doesn't get completed\nat all by the Camera. Thus the buffer is deallocated by\nSimpleCapture::stop(), and after SimpleCaptureBalanced::capture() exits,\nthe Request is destroyed and tries to cancel the deallocated buffer,\ncausing the segfault.\n\nFix this by reordering marking the Request for reuse so that it happens\nif and only if the Request wil be queued to the Camera.\n\nFixes: https://bugs.libcamera.org/show_bug.cgi?id=171\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/apps/lc-compliance/simple_capture.cpp | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)","diff":"diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp\nindex cf4d7cf3..4a05b919 100644\n--- a/src/apps/lc-compliance/simple_capture.cpp\n+++ b/src/apps/lc-compliance/simple_capture.cpp\n@@ -122,6 +122,7 @@ int SimpleCaptureBalanced::queueRequest(Request *request)\n \tif (queueCount_ > captureLimit_)\n \t\treturn 0;\n \n+\trequest->reuse(Request::ReuseBuffers);\n \treturn camera_->queueRequest(request);\n }\n \n@@ -133,7 +134,6 @@ void SimpleCaptureBalanced::requestComplete(Request *request)\n \t\treturn;\n \t}\n \n-\trequest->reuse(Request::ReuseBuffers);\n \tif (queueRequest(request))\n \t\tloop_->exit(-EINVAL);\n }\n","prefixes":["libcamera-devel","1/3"]}