Patch Detail
Show a patch.
GET /api/1.1/patches/13370/?format=api
{ "id": 13370, "url": "https://patchwork.libcamera.org/api/1.1/patches/13370/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13370/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210816143536.125939-1-umang.jain@ideasonboard.com>", "date": "2021-08-16T14:35:35", "name": "[libcamera-devel,v2,1/2] pipeline: vimc: Force complete of request on cancelled buffers", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "533a582a22bbe0d24a18c5a40ad2dbfee9ed206b", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": { "id": 12, "url": "https://patchwork.libcamera.org/api/1.1/users/12/?format=api", "username": "uajain", "first_name": "Umang", "last_name": "Jain", "email": "umang.jain@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/13370/mbox/", "series": [ { "id": 2361, "url": "https://patchwork.libcamera.org/api/1.1/series/2361/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2361", "date": "2021-08-16T14:35:35", "name": "[libcamera-devel,v2,1/2] pipeline: vimc: Force complete of request on cancelled buffers", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2361/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13370/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13370/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 F2031BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Aug 2021 14:35:45 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C1B668894;\n\tMon, 16 Aug 2021 16:35:45 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0DDC868891\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Aug 2021 16:35:44 +0200 (CEST)", "from perceval.ideasonboard.com (unknown [103.238.109.15])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 774423E5;\n\tMon, 16 Aug 2021 16:35:42 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TH5zs3vU\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629124543;\n\tbh=6VLvY7BV7lJLAzaEG59Q3FbqcQBEV5SrE7KmnVKQjo8=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=TH5zs3vUpb9Ji0v1uI3p1xagBUwOkNxGYf4oWiQWQRYGlEJq/knqi4TgXe4HR7hY+\n\tuoCcDQbnkWtNRulmoIH0JNkwgyc7J/EShwcNkRlkRpB3whN8v1bacnzA6xg15fU1Tw\n\tfjYR4SVh9LdI7ONDIT5TMFaeJGy1WrgSDeXwxYn4=", "From": "Umang Jain <umang.jain@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 16 Aug 2021 20:05:35 +0530", "Message-Id": "<20210816143536.125939-1-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/2] pipeline: vimc: Force complete of\n\trequest on cancelled buffers", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When the stream is stopped, the V4L2VideoDevice sends back all\nthe queued buffers with FrameMetadata::FrameCancelled status.\nIt is the responsibility of the pipeline handler to handle\nthese buffers with FrameMetadata::FrameCancelled. VIMC is\ncurrently missing this handling path.\n\nAs the FrameMetadata::FrameCancelled is set when the stream is\nstopped, we can be sure that no more queued and re-use of request\nshall happen. Hence, cancel all the requests' buffers force a\ncomplete with completeBuffer().\n\nThe issue is caught by the gstreamer_single_stream_test.cpp running\nwith vimc. During the check with meson built-in option\n\t'-Db_sanitize=address,undefined'\nit was observed:\n\n==118003==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e000037108 at pc 0x7f225160c9ac bp 0x7f224a47b620 sp 0x7f224a47b618\nREAD of size 4 at 0x60e000037108 thread T1\n #0 0x7f225160c9ab in libcamera::Request::sequence() const ../include/libcamera/request.h:55\n #1 0x7f22518297aa in libcamera::VimcCameraData::bufferReady(libcamera::FrameBuffer*) ../src/libcamera/pipeline/vimc/vimc.cpp:577\n #2 0x7f225183b1ef in libcamera::BoundMethodMember<libcamera::VimcCameraData, void, libcamera::FrameBuffer*>::activate(libcamera::FrameBuffer*, bool) ../include/libcamera/base/bound_method.h:194\n #3 0x7f22515cc91f in libcamera::Signal<libcamera::FrameBuffer*>::emit(libcamera::FrameBuffer*) ../include/libcamera/base/signal.h:126\n #4 0x7f22515c3305 in libcamera::V4L2VideoDevice::streamOff() ../src/libcamera/v4l2_videodevice.cpp:1605\n #5 0x7f225181f345 in libcamera::PipelineHandlerVimc::stop(libcamera::Camera*) ../src/libcamera/pipeline/vimc/vimc.cpp:365\n\nThe VimcCameraData::bufferReady seems to emit even after the stream\nis stopped. It's primarily due to vimc's lack of handling\nFrameMetadata::FrameCancelled in its pipeline handler.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nTested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/vimc/vimc.cpp | 12 ++++++++++++\n 1 file changed, 12 insertions(+)", "diff": "diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 92b30f2e..1a6b8ae2 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -567,6 +567,18 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n {\n \tRequest *request = buffer->request();\n \n+\t/* If the buffer is cancelled force a complete of the whole request. */\n+\tif (buffer->metadata().status == FrameMetadata::FrameCancelled) {\n+\t\tfor (auto it : request->buffers()) {\n+\t\t\tFrameBuffer *b = it.second;\n+\t\t\tb->cancel();\n+\t\t\tpipe_->completeBuffer(request, b);\n+\t\t}\n+\n+\t\tpipe_->completeRequest(request);\n+\t\treturn;\n+\t}\n+\n \t/* Record the sensor's timestamp in the request metadata. */\n \trequest->metadata().set(controls::SensorTimestamp,\n \t\t\t\tbuffer->metadata().timestamp);\n", "prefixes": [ "libcamera-devel", "v2", "1/2" ] }