{"id":19562,"url":"https://patchwork.libcamera.org/api/1.1/patches/19562/?format=json","web_url":"https://patchwork.libcamera.org/patch/19562/","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":"<20240227175336.560009-2-nicolas@ndufresne.ca>","date":"2024-02-27T17:53:34","name":"[v1,1/3] gstreamer: allocator: Ensure camera manager stay alive","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"696f1616e79922b6e920edcbcffe32b01cbc214a","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/1.1/people/30/?format=json","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19562/mbox/","series":[{"id":4190,"url":"https://patchwork.libcamera.org/api/1.1/series/4190/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4190","date":"2024-02-27T17:53:33","name":"gstreamer: Fix a crash when memory outlives the pipeline","version":1,"mbox":"https://patchwork.libcamera.org/series/4190/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19562/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19562/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 588DDBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Feb 2024 17:54:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1ADDC62867;\n\tTue, 27 Feb 2024 18:54:02 +0100 (CET)","from madrid.collaboradmins.com (madrid.collaboradmins.com\n\t[IPv6:2a00:1098:ed:100::25])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04B2E6285F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Feb 2024 18:54:00 +0100 (CET)","from nicolas-tpx395.lan (cola.collaboradmins.com [195.201.22.229])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby madrid.collaboradmins.com (Postfix) with ESMTPSA id 32447378000B; \n\tTue, 27 Feb 2024 17:53:59 +0000 (UTC)"],"From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1 1/3] gstreamer: allocator: Ensure camera manager stay\n\talive","Date":"Tue, 27 Feb 2024 12:53:34 -0500","Message-ID":"<20240227175336.560009-2-nicolas@ndufresne.ca>","X-Mailer":"git-send-email 2.43.2","In-Reply-To":"<20240227175336.560009-1-nicolas@ndufresne.ca>","References":"<20240227175336.560009-1-nicolas@ndufresne.ca>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Cc":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nWith the camera manager, it is not possible to cleanly delete the\nFrameBufferAllocator object. Keep the camera manager alive until all the\nmemory object have been released.\n\nFixes: Bugzilla issue 211\nSigned-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n src/gstreamer/gstlibcameraallocator.cpp | 16 +++++++++++++++-\n 1 file changed, 15 insertions(+), 1 deletion(-)","diff":"diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp\nindex c740b8fc..844bdb17 100644\n--- a/src/gstreamer/gstlibcameraallocator.cpp\n+++ b/src/gstreamer/gstlibcameraallocator.cpp\n@@ -100,6 +100,11 @@ struct _GstLibcameraAllocator {\n \t * FrameWrap.\n \t */\n \tGHashTable *pools;\n+\t/*\n+\t * The camera manager represent that library, which needs to be kept alive\n+\t * until all the memory have been released.\n+\t */\n+\tstd::shared_ptr<CameraManager> *cm_ptr;\n };\n \n G_DEFINE_TYPE(GstLibcameraAllocator, gst_libcamera_allocator,\n@@ -173,6 +178,9 @@ gst_libcamera_allocator_finalize(GObject *object)\n \n \tdelete self->fb_allocator;\n \n+\t/* keep last */\n+\tdelete self->cm_ptr;\n+\n \tG_OBJECT_CLASS(gst_libcamera_allocator_parent_class)->finalize(object);\n }\n \n@@ -193,11 +201,17 @@ gst_libcamera_allocator_new(std::shared_ptr<Camera> camera,\n {\n \tauto *self = GST_LIBCAMERA_ALLOCATOR(g_object_new(GST_TYPE_LIBCAMERA_ALLOCATOR,\n \t\t\t\t\t\t\t  nullptr));\n+\tgint ret;\n+\n+\tself->cm_ptr = new std::shared_ptr<CameraManager>(gst_libcamera_get_camera_manager(ret));\n+\tif (ret) {\n+\t\tg_object_unref(self);\n+\t\treturn nullptr;\n+\t}\n \n \tself->fb_allocator = new FrameBufferAllocator(camera);\n \tfor (StreamConfiguration &streamCfg : *config_) {\n \t\tStream *stream = streamCfg.stream();\n-\t\tgint ret;\n \n \t\tret = self->fb_allocator->allocate(stream);\n \t\tif (ret == 0)\n","prefixes":["v1","1/3"]}