From nobody Sun Feb 8 17:55:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687357197; cv=none; d=zohomail.com; s=zohoarc; b=ZjypiWlpP1HQ5FPchxuFvtTK/ZinHDEEprc4n+Vw9LCTlRl4qO3IQ0HLYo99Nzair3JFUgUKrE8t+awqB2iMVPFFWwRqX6oSmBoDCPVmUpWRpaaAMT+w4qOAB58YCvSBzAz/EIuduXGr34NzbXiR/iRdjfEbDU5YCJPq3MO/OL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687357197; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KN8lRPBnHS0RorqxHTudghyF2wFWa1wEQ0Bvgwbyj0g=; b=DZwlzs8xJUtkk6ib2K9UxYCBLSYApDK1zdJFXLSyB+3ahtE01Ndndyyec5KC8jdrBKE7uDh+ND4crK3sKrSUnX+D94DR+YFK/BGWaMHivZI664OqG1idk2EchRnSGe3SzIOHxfqNd7dAUQbYxBMf2+fayF9XUB4lo1D+FbJCUvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1687357197002760.7075128189117; Wed, 21 Jun 2023 07:19:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-M5ulZTNHNzql8rsLpzg7nw-1; Wed, 21 Jun 2023 10:19:32 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 308621C319E5; Wed, 21 Jun 2023 14:09:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D897492C13; Wed, 21 Jun 2023 14:09:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B3931946A42; Wed, 21 Jun 2023 14:09:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58B8B194658C for ; Wed, 21 Jun 2023 14:09:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 201D3C1ED96; Wed, 21 Jun 2023 14:09:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7868C1ED97 for ; Wed, 21 Jun 2023 14:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687357196; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KN8lRPBnHS0RorqxHTudghyF2wFWa1wEQ0Bvgwbyj0g=; b=GgBBlx3HlJwDYKAVqzLun8wYIBIG4PJkrdrKyKuE7q0/To6/2ZBcG0QsM81Tnw2AQTwaMz xN0Sn7G5bJaSG6N8JZJ8niMeth4Sv32iKRTMA0Msm2y9CQW1PX9FggVnyU8yUF0RfneIC1 c9Ya6OCiBTh0QXseHusB4f+odeCM4Og= X-MC-Unique: M5ulZTNHNzql8rsLpzg7nw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] virGlobalInit: Make glib init its own global state Date: Wed, 21 Jun 2023 16:09:11 +0200 Message-Id: <0a91987d4d027f74756c7b1d2dba4d1024f20160.1687356000.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687357199011100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This should not be needed, but here's what's happening: virStrToLong_*() family of functions was switched from strtol*() to g_ascii_strtol*() in order to handle corner cases on Windows (most notably parsing hex numbers with base=3D0) - see v9.4.0-61-g2ed41d7cd9. But what we did not realize back then, is the fact that g_ascii_strtol*() family has their own global lock rendering virStrToLong_*() function unsafe between fork() + exec(). Worse, if one of the threads has to wait for the lock (or on its corresponding condition), then errno is mangled and g_ascii_strtol*() signals an error, even though there's no error. Read more here: https://gitlab.gnome.org/GNOME/glib/-/issues/3034 Nevertheless, if we make glib init the g_ascii_strtol*() global state (by calling one function from g_ascii_strtol*() family), then there shouldn't be any congestion on the lock and thus no errno mangling. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libvirt.c b/src/libvirt.c index 2e470adf98..69d5b13bff 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -214,6 +214,14 @@ virGlobalInit(void) if (virErrorInitialize() < 0) goto error; =20 + /* Make glib initialize its own global state. See more: + * + * https://gitlab.gnome.org/GNOME/glib/-/issues/3034 + * + * TODO: Remove ASAP. + */ + g_ascii_strtoull("0", NULL, 0); + virFileActivateDirOverrideForLib(); =20 if (getuid() !=3D geteuid() || --=20 2.39.3