From patchwork Fri Nov 20 20:06:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 29064 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 17AAAC3304 for ; Fri, 20 Nov 2026 20:06:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 512246A94D; Fri, 20 Nov 2026 21:06:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WmUE93Wd"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E15C6A936 for ; Fri, 20 Nov 2026 21:06:41 +0100 (CET) Received: from pb-laptop.local (185.182.215.119.nat.pool.zt.hu [185.182.215.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F265F6AF for ; Fri, 20 Nov 2026 21:04:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1795205051; bh=nlHOTzsanLVt/S9P2GLn0ShC7/zb80PLG7kxfCq+G3c=; h=From:To:Subject:Date:From; b=WmUE93WdYDbH9lpA3MA8WIrue1+OzMBgFzIAOpWKDoKkvLUNWE8OG+vsRBXbRgSsa HtFo/blHbSdvum9rheeiXIHx+AQKJLZK2qgyBT1WDYN2Mrs6XqueqLTio5FbvnZtTz bNIVLt6Z7TLIb1VmixNH/miDWDs069wlxpm3i3Zk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] gstreamer: Disconnect request completion signal Date: Fri, 20 Nov 2026 21:06:37 +0100 Message-ID: <20261120200637.802757-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The request completion signal must be disconnected when the camera is disassociated from the gstreamer state. Otherwise, if the same `Camera` is opened and used again, the signal handler might be called on the stale (potentially already freed) state, which will either be a use-after-free, or a potential assertion failure when the front of the (stale) `queuedRequests_` is accessed. This is because the signals of a `Camera` are shared between all users, and they are not automatically disconnected when `release()`d, etc. So great care must be taken not to leave "dangling" receivers on signals. So disconnect the signal in `gst_libcamera_src_close()`, the opposite operation of `gst_libcamera_src_open()`, where the signal is connected. Note that this issue depends on the same `Camera` object being used, so it requires the `CameraManager` to stay alive between the close and reopen steps. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/377 Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- src/gstreamer/gstlibcamerasrc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 9541aa3f69..cf61939f1e 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -981,6 +981,8 @@ gst_libcamera_src_close(GstLibcameraSrc *self) ("libcamera::Camera.release() failed: %s", g_strerror(-ret))); } + state->cam_->requestCompleted.disconnect(state); + state->cam_.reset(); state->cm_.reset(); }