{"id":15015,"url":"https://patchwork.libcamera.org/api/1.1/patches/15015/?format=json","web_url":"https://patchwork.libcamera.org/patch/15015/","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":"<20211203164619.1541033-3-hiroh@chromium.org>","date":"2021-12-03T16:46:14","name":"[libcamera-devel,2/7] libcamera: base: thread: Protect exitCode by mutex in exit()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4b6e5151b237637fecb5d516e5724bdb6b518c8b","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15015/mbox/","series":[{"id":2812,"url":"https://patchwork.libcamera.org/api/1.1/series/2812/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2812","date":"2021-12-03T16:46:12","name":"Apply clang thread safety annotation libcamera-core and v4l2","version":1,"mbox":"https://patchwork.libcamera.org/series/2812/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15015/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15015/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 51614BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Dec 2021 16:46:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A38B660839;\n\tFri,  3 Dec 2021 17:46:32 +0100 (CET)","from mail-pl1-x635.google.com (mail-pl1-x635.google.com\n\t[IPv6:2607:f8b0:4864:20::635])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BD3760822\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Dec 2021 17:46:30 +0100 (CET)","by mail-pl1-x635.google.com with SMTP id y8so2520197plg.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Dec 2021 08:46:30 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:cd78:3a5f:d792:6177])\n\tby smtp.gmail.com with ESMTPSA id\n\th18sm4123149pfh.172.2021.12.03.08.46.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Dec 2021 08:46:27 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"btAo1BcM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=w4rnq1G43kcabXi0+eiMWXx37SsnfadSaV/7HNh2lW0=;\n\tb=btAo1BcMbMj+RinFkMTr88KsEwPLFIf0Vv8Mh7oUoiSG9ayAzkN09MTXpZML4aylB+\n\typOmnSuAuW1O/mDnkknj1lT+oJLtTHkkUptVMZdsGBH4KJVTCvE1rzkbg97zMgpDpacr\n\tEMJTuJ1Ppk+iy6+w+19O/q/Ay80A3HBcjJJ1U=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=w4rnq1G43kcabXi0+eiMWXx37SsnfadSaV/7HNh2lW0=;\n\tb=vafoh5Px3X/+5Bcq4IhICwo+XeFTW1SDVlHyt5MQQsTvLmU8uTgEWDV+7+cDxarX4U\n\teIJ61l+SzNhu5UY+gv09suseo1Q/NOEeQXcwStUMitoMYwnkd09ahRGdIdfLuu/vgAG7\n\tX+ZkgPkFVNWF5id/mdzudtZf7vP2mEnXnFDTwqEsG0eNR45bV0B6uvtCZoYMhfZjL+Fw\n\tefjpJefuRRoDboUWbe1Rca4aT8tiZSv9YgpUdG413Htt9ODic7wtnDmCo+9yWxFBCpE2\n\tP/0vsIdFkZhf1wFO7pMu6Sg3TTLI500cDoXn8gha1cmVsdFRT874E+orHea5rC2KsMA5\n\tqmiw==","X-Gm-Message-State":"AOAM532nqzcTObxmj+Zwu12FLwLnmmOI/go2syktDhJrymevgc6M2zD2\n\tpwwy0QNGHROwveNYKUx0FPZ6+Qyoijuk1A==","X-Google-Smtp-Source":"ABdhPJysUbbtNx4EPcXgpwaNS2CTGkU7ntO6GRhNWKzjlqS/lU8q/lt6ZfvQALPttB7TdWRhLhLCAw==","X-Received":"by 2002:a17:902:c3cc:b0:141:be17:405e with SMTP id\n\tj12-20020a170902c3cc00b00141be17405emr23932328plj.76.1638549988315; \n\tFri, 03 Dec 2021 08:46:28 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 Dec 2021 01:46:14 +0900","Message-Id":"<20211203164619.1541033-3-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.384.gca35af8252-goog","In-Reply-To":"<20211203164619.1541033-1-hiroh@chromium.org>","References":"<20211203164619.1541033-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/7] libcamera: base: thread: Protect\n\texitCode by mutex in exit()","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":"This fixes the bug that Thread::exit() accesses data_->exitCode\nwithout acquiring a lock.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/libcamera/base/thread.cpp | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp\nindex 6bda9d14..abd33a83 100644\n--- a/src/libcamera/base/thread.cpp\n+++ b/src/libcamera/base/thread.cpp\n@@ -390,9 +390,11 @@ void Thread::finishThread()\n  *\n  * \\context This function is \\threadsafe.\n  */\n-void Thread::exit(int code)\n+void Thread::exitint code)\n {\n+\tdata_->mutex_.lock();\n \tdata_->exitCode_ = code;\n+\tdata_->mutex_.unlock();\n \tdata_->exit_.store(true, std::memory_order_release);\n \n \tEventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_relaxed);\n","prefixes":["libcamera-devel","2/7"]}