From patchwork Tue Aug 11 13:00:34 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: 27750 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 9B7E1C3259 for ; Tue, 11 Aug 2026 13:00:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E49CD68261; Tue, 11 Aug 2026 15:00:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sCT/wccz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C67196824B for ; Tue, 11 Aug 2026 15:00:45 +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 E73E51049 for ; Tue, 11 Aug 2026 14:59:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1786453171; bh=Pc+VJsLbn7SNxXXrd2VhgEi7WNT51YJcGpzNA1YNqFc=; h=From:To:Subject:Date:From; b=sCT/wcczYim0p7PDQJBMDN9MvszcDO42bRSvu48r9iTLfI2sX7eBkuuQpETWQhCnM 5fHvxv7jMRxo06ZQlIX7i8fKYUOpsUpFgfrIHn6g0wDOSD5wZ3+VxotTYrYNsiefhv xmy/D6gBbfrA2R5rLMlqjUWLcci5SUJ1CHG+ggfg= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 0/8]libcamera: software_isp: debayer_egl: Remove some leaks Date: Tue, 11 Aug 2026 15:00:34 +0200 Message-ID: <20260811130042.213139-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. For example, in one test: 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). changes in v3: * require `resetEGLContext()` and assert in the destructor * use the thread check function from v2 internally as well changes in v2: * drop the explicit context un-make and move it into `resetEGLContext()` * assert the appropriate thread after the removal of the explicit make-context call v2: https://patchwork.libcamera.org/cover/27722/ v1: https://patchwork.libcamera.org/cover/27602/ Barnabás Pőcze (8): 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 `assertThread()` libcamera: software_isp: debayer_egl: Remove EGL context switch libcamera: software_isp: debayer_egl: Avoid EGL context leaks libcamera: egl: initEGLContext(): Avoid double init include/libcamera/internal/egl.h | 24 ++-- src/libcamera/egl.cpp | 131 ++++++++++----------- src/libcamera/software_isp/debayer_egl.cpp | 8 +- 3 files changed, 82 insertions(+), 81 deletions(-) --- 2.55.0