From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EQU5L5Pd7Gp1kSIAWB0awg (envelope-from ) for ; Thu, 05 Nov 2026 14:48:35 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=lists.lttng.org header.i=@lists.lttng.org header.a=rsa-sha256 header.s=default header.b=kWFZ4nYK; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BD24D378002; Thu, 05 Nov 2026 14:48:35 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from lists.lttng.org (lists.lttng.org [158.69.130.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C3A461E043 for ; Thu, 05 Nov 2026 14:48:34 -0500 (EST) ARC-Filter: OpenARC Filter v1.2.1 lists.lttng.org 4jLCXr0wqRz1y8W ARC-Seal: i=1; d=lists.lttng.org; s=arc1; a=rsa-sha256; cv=none; t=1793908108; b=LblGWb3TY+yTIpoG8oFR64csjC0JIeK1Yhw28UNDWaIytiiqPIKfAGkYwHR69jEvfDOy Uk+9e1ZKIS3OSsLYUtASFO9Ztdc9nHrlTsByil3Rt6arwsZ05AurBaenYaCR6SelN7ot4 cZsSC46lHB32wVnqf9oHeRjvyPao/w1ZZtFW9KJjXC5rDnfR1WKQnmokcTga8zkYDwPQb RI94nqnPkXoxaX2Z7CcC/t8hwkyq8YssNr5AzSfuEc01KdsdjutUCg7GGrrt81LipqQug j8PWZO+BQbBIGSjq7Ui4L32sdskzLMA7Ee50ksyjltWtLIOBv4P/q4y89rFxdbf7C3g== ARC-Message-Signature: i=1; d=lists.lttng.org; s=arc1; a=rsa-sha256; c=relaxed/simple; t=1793908108; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From:From; bh=fsRu2SBKcmMT+8al5m5FWnedz5U9nlJFv5tmcrbr39M=; b=fMz3aXiPm3vk+c+IGQH9B5HQDAY7D12JRjftNM+qDshqaZQ8E7Nhyv2RQAPFaEPgNFOP qW8NrkO6iV6zJ+w9EU2BjpmTDo+81sfyPkIAduP2QtjUeP6axfdMri5dazZ26deqDzBeZ FkqISkBq4AwSO16JhxcX4OnjVfb+f4jhMhfm8NjUg1gJkDVmApqycilz2B4anV6wI/EjT rLEvnSBWyRpZEuH2NXkbi6aopaYQSJqTPPzBdxXWg0FdovnYffueSBRJrr+EgRoIaA1fN BKfmFc1IWi4XdkW8LOfA/RzEExW/e9uK4hgiDs01qevjO7SahJt4SfZXQM0yF7QbPfg== ARC-Authentication-Results: i=1; lists.lttng.org; arc=none smtp.remote-ip="::1" DKIM-Filter: OpenDKIM Filter v2.11.0 lists.lttng.org 4jLCXr0wqRz1y8W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.lttng.org; s=default; t=1793908108; bh=ivxPLPzdy0PS1AVCiEKWQwxC9MlyWnbTKgBP5TBKuQM=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kWFZ4nYKtoNYtA7NfzFi7BuFHcVfJt+ATsgldahBEQa463BjJ7QHN86KrabY9v8QH UrcziQP+xrxulfKsR22dwTX58uaKs1toIt6BCFPKIS3w6BQgfi+9sQZwI6/VclD+X0 l4HHhcqBIjzlj/fAU/JqPQ0mA5Uzhq14hKhb+OC+DQheau7vXKns8vlcYv3OJE4W6l sfPhW3WRvfv6MSq89mqAU4XCrHKCviT10swFMtXk2NBvee9Z0lJe9Q3V1lJ84QKF8m L+x6bdpBlwNjpIncXn/KGujNiWl2cWmLQGgsne7MBtEeC4Bj477gyM0jJgjLTBe+vv ur0bWQQR1oGWA== Received: from lists-lttng01.efficios.com (localhost [IPv6:::1]) by lists.lttng.org (Postfix) with ESMTP id 4jLCXr0wqRz1y8W; Thu, 5 Nov 2026 14:48:27 -0500 (EST) ARC-Filter: OpenARC Filter v1.2.1 lists.lttng.org 4jLCXq0bcRz1y8P DKIM-Filter: OpenDKIM Filter v2.11.0 lists.lttng.org 4jLCXq0bcRz1y8P Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by lists.lttng.org (Postfix) with ESMTPS id 4jLCXq0bcRz1y8P for ; Thu, 5 Nov 2026 14:48:26 -0500 (EST) Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 6A5JmKgq225230 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Nov 2026 14:48:25 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6A5JmKgq225230 Received: by simark.ca (Postfix) id 31D201E043; Thu, 05 Nov 2026 14:48:20 -0500 (EST) Message-ID: <401fff05-cde1-4cb0-b421-132192bb7366@polymtl.ca> Date: Thu, 5 Nov 2026 14:48:19 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: libbabeltrace2: question about thread safety To: "MOESSBAUER, Felix" , "lttng-dev@lists.lttng.org" References: <44074c36528ca4a30909e21072ae67f37b0c244b.camel@siemens.com> Content-Language: fr In-Reply-To: <44074c36528ca4a30909e21072ae67f37b0c244b.camel@siemens.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Nov 2026 19:48:20 +0000 X-BeenThere: lttng-dev@lists.lttng.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: LTTng development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via lttng-dev Reply-To: Simon Marchi Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" On 10/23/26 4:11 AM, MOESSBAUER, Felix via lttng-dev wrote: > Hi, > > I just noticed that the reference counting in libbabeltrace2 is not > atomic - and by that not thread safe. As I can't know where reference > counting on global objects (like the plugin or component instances) is > done internally, I'm assuming I can't execute two (independent) graphs > in parallel. Some quick tests with tsan seem to confirm my assumption. > > Is there any (documented) way to run two graphs in parallel? Or shall > the whole library just be used behind a global mutex? (resending from another address to try to avoid the spam filter) I think the idea was that running two graphs simultaneously in two threads would not be a problem, because they don't share anything. But you are right that plugins and component classes are actually shared. The action of adding a component to a graph touches the component class' refcount, and so does destroying the graph (and there is the "freeze" status too, if the lib is built in dev mode). I think it would make sense for libbabeltrace2 to have some synchronization in the plugin / component class area to allow for two threads to build, run and destroy graphs without requiring any locking on the user side. But that won't be trivial, and it's not on the roadmap as we speak. In the mean time, you could try having a global lock but only for the graph building and destruction phases? Or have a single thread responsible for building and destroying graphs. I'd be curious to know if this is enough or if there are other concurrent accesses we haven't spotted. Simon