From patchwork Tue Aug 4 10:19:39 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: 27602 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 DBD03C3301 for ; Tue, 4 Aug 2026 10:19:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C8366809C; Tue, 4 Aug 2026 12:19:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vyqUA70v"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6688F67F9E for ; Tue, 4 Aug 2026 12:19:52 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A52951C76 for ; Tue, 4 Aug 2026 12:18:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838722; bh=73GLlYHZqzeWtEsKXpBYJzrBZjjFRBnRuDZljroMRzU=; h=From:To:Subject:Date:From; b=vyqUA70vFoIBYpuekYH5iVa3g2Z/xL/KwAa/z+tEuz/gqGFbPCp2Vc6tRg+/FM9oi l9GsAyMjdNdva7XoJwXPA8e2L/VBP9j39rBUEorK1y70U0x+6nVYHCTa4CX20qrmiO K5t7uGauOKkUZh6dNWU+p5ubEEmNMktg3T/Az8y4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 00/10] libcamera: software_isp: debayer_egl: Remove some leaks Date: Tue, 4 Aug 2026 12:19:39 +0200 Message-ID: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 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" Currently `eGL::initEGLContext()` is called each time the camera is started, so the `EGLContext` is leaked if the camera is started more than once. Furthermore, mesa does not seem to have any thread destructors to clean up the bound context when the thread is stopped. So these are some RFC changes intended to address the above leaks. (As well some other small changes.) The effects can be observed with asan and e.g. $ lc-compliance -f '*CaptureStartStop/StillCapture__8' -c '\_SB_.PC00.LNK1' (which does 3 start-stop sequences) but I have also extended `cam` to be able to repeat the capture sessions, and that very clearly shows a start-stop leak: before: repeat | result 4 | SUMMARY: AddressSanitizer: 8979617 byte(s) leaked in 72738 allocation(s). 8 | SUMMARY: AddressSanitizer: 17536873 byte(s) leaked in 144057 allocation(s). 16 | SUMMARY: AddressSanitizer: 34717529 byte(s) leaked in 286697 allocation(s). 32 | SUMMARY: AddressSanitizer: 69078457 byte(s) leaked in 571977 allocation(s). after: repeat | result 32 | SUMMARY: AddressSanitizer: 487117 byte(s) leaked in 1425 allocation(s). Barnabás Pőcze (10): libcamera: egl: Remove `gl{Use,Delete}Program()` libcamera: egl: Remove `eGL::surface_` libcamera: egl: Do not load `glGetString` dynamically libcamera: egl: Ensure all members are always initialized libcamera: egl: Add `resetEGLContext()` libcamera: software_isp: debayer_egl: Avoid EGL context leaks libcamera: egl: initEGLContext(): Avoid double init libcamera: software_isp: debayer_egl: Remove EGL context switch libcamera: egl: Make it possible to unmake the context libcamera: software_isp: debayer_egl: Unmake EGL context include/libcamera/internal/egl.h | 17 ++-- src/libcamera/egl.cpp | 97 +++++++++------------- src/libcamera/software_isp/debayer_egl.cpp | 8 +- 3 files changed, 49 insertions(+), 73 deletions(-) --- 2.55.0