{"id":3942,"url":"https://patchwork.libcamera.org/api/1.1/patches/3942/?format=json","web_url":"https://patchwork.libcamera.org/patch/3942/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200605090106.15424-8-paul.elder@ideasonboard.com>","date":"2020-06-05T09:01:06","name":"[libcamera-devel,v2,7/7] v4l2: v4l2_camera_proxy: Fix segfault on restarting streams","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"24cea2ad09f34ec8d3cc1aab30b05deb0670fa70","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3942/mbox/","series":[{"id":956,"url":"https://patchwork.libcamera.org/api/1.1/series/956/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=956","date":"2020-06-05T09:00:59","name":"Support qv4l2 with v4l2-compat","version":2,"mbox":"https://patchwork.libcamera.org/series/956/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3942/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3942/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["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 F01946124F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Jun 2020 11:01:26 +0200 (CEST)","from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp\n\t[118.238.243.68])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C7CC227C;\n\tFri,  5 Jun 2020 11:01:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QDIG04Jd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1591347686;\n\tbh=5qweElhF0wT6dCUQnqxn3x3FOoB0mlpHWKTIFoMp5eQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QDIG04Jdn5sWHF+rciXkRtWNdVJz+CnRyalRSIPvwuP12n3/ByAxWoqvBNqnOFwHk\n\tlyqHzVPxgp3gzozEpbrQXog9m+E3OfE0UVmnpWb/MGh9WuB+/gPl8zftTuISbIDfJh\n\tEL6KhVqjYeiZHajzya89H+/FG+oePzNI+zWAabro=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  5 Jun 2020 18:01:06 +0900","Message-Id":"<20200605090106.15424-8-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200605090106.15424-1-paul.elder@ideasonboard.com>","References":"<20200605090106.15424-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 7/7] v4l2: v4l2_camera_proxy: Fix\n\tsegfault on restarting streams","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>","X-List-Received-Date":"Fri, 05 Jun 2020 09:01:27 -0000"},"content":"The V4L2 compatibility layer keeps track of the index of the next buffer\nto be dequeued, to handle VIDIOC_DQBUF. This index is set to 0 on\nstartup and incremented (modulo #frames), and is otherwise never reset.\nThis means that if the last handled frame index is not #frames-1, and\nthe stream is restarted without restarting libcamera and the V4L2\ncompatilibity layer, the buffer index number won't match with the\nlibcamera buffer index number, causing a segfault. Fix this by resetting\nthe current buffer index to zero on VIDIOC_STREAMON.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v2\n---\n src/v4l2/v4l2_camera_proxy.cpp | 2 ++\n 1 file changed, 2 insertions(+)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 7ee4c0cb..059f3cbe 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -465,6 +465,8 @@ int V4L2CameraProxy::vidioc_streamon(int *arg)\n \tif (!validateBufferType(*arg))\n \t\treturn -EINVAL;\n \n+\tcurrentBuf_ = 0;\n+\n \treturn vcam_->streamOn();\n }\n \n","prefixes":["libcamera-devel","v2","7/7"]}