{"id":24986,"url":"https://patchwork.libcamera.org/api/patches/24986/?format=json","web_url":"https://patchwork.libcamera.org/patch/24986/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20251111084133.2292217-1-barnabas.pocze@ideasonboard.com>","date":"2025-11-11T08:41:33","name":"[v1] libcamera: base: thread: Use `pthread_self()` when setting name","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"06d11ca4f2eba09664222f652f280505c8c330c7","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24986/mbox/","series":[{"id":5570,"url":"https://patchwork.libcamera.org/api/series/5570/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5570","date":"2025-11-11T08:41:33","name":"[v1] libcamera: base: thread: Use `pthread_self()` when setting name","version":1,"mbox":"https://patchwork.libcamera.org/series/5570/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24986/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24986/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 12D2FC3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 11 Nov 2025 08:41:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F17260A8B;\n\tTue, 11 Nov 2025 09:41:38 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 674B260805\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Nov 2025 09:41:36 +0100 (CET)","from pb-laptop.local (185.221.140.239.nat.pool.zt.hu\n\t[185.221.140.239])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B70F4B0B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Nov 2025 09:39:37 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"GCWf+TEQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762850377;\n\tbh=VUNm/8fgzUR7RW1g1qWozUNQAISedfuP7gMXmwCQ5V8=;\n\th=From:To:Subject:Date:From;\n\tb=GCWf+TEQF/n0qI+s8+t01yLFU6TCgf+vqMQBX4Yn74dgROW3XJ2Ge5/SqeGDU/l/Y\n\tar9UWY/pB2WpUZbVxOVMkRuBE7vOHbcFLoSsigAUzIGAhUYW30xW2GXbg3H8z1f3f+\n\txzvXoVTsc3zha854DKxmbqF8pxQwpouqyXISae00=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1] libcamera: base: thread: Use `pthread_self()` when\n\tsetting 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","Content-Type":"text/plain; charset=UTF-8","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"There is a data race between `Thread::start()` writing `Thread::thread_`\nand `Thread::startThread()` reading it. Avoid it by using `pthread_self()`\nto get the id of the current thread instead of using the `thread_` member.\n\nThis is at least the second time this issue occurs:\nhttps://lists.libcamera.org/pipermail/libcamera-devel/2025-January/047954.html\n\nFixes: 559128b1f1b3cf (\"Thread: Add name parameter\")\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/base/thread.cpp | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\nindex 39209ec8ad..b94a3d7490 100644\n--- a/src/libcamera/base/thread.cpp\n+++ b/src/libcamera/base/thread.cpp\n@@ -292,8 +292,7 @@ void Thread::startThread()\n \tcurrentThreadData = data_.get();\n \n \tif (!name_.empty())\n-\t\tpthread_setname_np(thread_.native_handle(),\n-\t\t\t\t   name_.substr(0, 15).c_str());\n+\t\tpthread_setname_np(pthread_self(), name_.substr(0, 15).c_str());\n \n \trun();\n }\n","prefixes":["v1"]}