From patchwork Tue Nov 11 08:41:33 2025 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: 24986 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 12D2FC3241 for ; Tue, 11 Nov 2025 08:41:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F17260A8B; Tue, 11 Nov 2025 09:41:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GCWf+TEQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 674B260805 for ; Tue, 11 Nov 2025 09:41:36 +0100 (CET) Received: from pb-laptop.local (185.221.140.239.nat.pool.zt.hu [185.221.140.239]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B70F4B0B for ; Tue, 11 Nov 2025 09:39:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762850377; bh=VUNm/8fgzUR7RW1g1qWozUNQAISedfuP7gMXmwCQ5V8=; h=From:To:Subject:Date:From; b=GCWf+TEQF/n0qI+s8+t01yLFU6TCgf+vqMQBX4Yn74dgROW3XJ2Ge5/SqeGDU/l/Y ar9UWY/pB2WpUZbVxOVMkRuBE7vOHbcFLoSsigAUzIGAhUYW30xW2GXbg3H8z1f3f+ xzvXoVTsc3zha854DKxmbqF8pxQwpouqyXISae00= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] libcamera: base: thread: Use `pthread_self()` when setting name Date: Tue, 11 Nov 2025 09:41:33 +0100 Message-ID: <20251111084133.2292217-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.2 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" There is a data race between `Thread::start()` writing `Thread::thread_` and `Thread::startThread()` reading it. Avoid it by using `pthread_self()` to get the id of the current thread instead of using the `thread_` member. This is at least the second time this issue occurs: https://lists.libcamera.org/pipermail/libcamera-devel/2025-January/047954.html Fixes: 559128b1f1b3cf ("Thread: Add name parameter") Signed-off-by: Barnabás Pőcze Reviewed-by: Daniel Scally Reviewed-by: Laurent Pinchart --- src/libcamera/base/thread.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 39209ec8ad..b94a3d7490 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -292,8 +292,7 @@ void Thread::startThread() currentThreadData = data_.get(); if (!name_.empty()) - pthread_setname_np(thread_.native_handle(), - name_.substr(0, 15).c_str()); + pthread_setname_np(pthread_self(), name_.substr(0, 15).c_str()); run(); }