From nobody Mon Feb 9 04:17:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1741953266671224.24058432791787; Fri, 14 Mar 2025 04:54:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A2FCB18A2; Fri, 14 Mar 2025 07:54:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E71EC2285; Fri, 14 Mar 2025 07:53:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C57C819A5; Fri, 14 Mar 2025 07:53:38 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 43A0C1AAB for ; Fri, 14 Mar 2025 07:53:28 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-6m4C-6CrOZ6PK98RL9oi2w-1; Fri, 14 Mar 2025 07:53:26 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D118E1801A06 for ; Fri, 14 Mar 2025 11:53:25 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.44.32.138]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 334941955F2D; Fri, 14 Mar 2025 11:53:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741953207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ihcykBUIOl6wJRxclQ/24MR964Ddc2LPlIeoMgR8Llc=; b=AFpp7IMJdmpDVmnpTLyN2yABjQ1rBvw4S8KoKzfR1LouZ9qc1qU9GQ/Wmham6AcHp/juBr gEpRbWqSbj4lcZc61boU7cfvBcFZYx66R6DSM3qHH6x0phSHHMKFVx+b1sIxm8KY3D3rcr 2MgieJRM260n6MAEBNytRYvo9s4PP9g= X-MC-Unique: 6m4C-6CrOZ6PK98RL9oi2w-1 X-Mimecast-MFC-AGG-ID: 6m4C-6CrOZ6PK98RL9oi2w_1741953205 From: Kirill Shchetiniuk To: devel@lists.libvirt.org Subject: [PATCH 2/2] ch: ref count fix in virCHEventHandlerLoop and virCHStartEventHandler Date: Fri, 14 Mar 2025 12:51:19 +0100 Message-ID: <20250314115236.53057-4-kshcheti@redhat.com> In-Reply-To: <20250314115236.53057-2-kshcheti@redhat.com> References: <20250314115236.53057-2-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SBkfbJj5HXNcZNpQUhttt88UkWNengnWbXrZEHC-YgY_1741953205 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: R4YRTU54V23O5ASUIANZOXSYRDGASSAH X-Message-ID-Hash: R4YRTU54V23O5ASUIANZOXSYRDGASSAH X-MailFrom: kshcheti@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Kirill Shchetiniuk X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1741953267872019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Monitor Reference Counting Fix: The monitor was being unreferenced inside virCHEventHandlerLoop, that has led to a segmentation fault. The monitor was unreferenced after successful child thread creation while it was still being used in the child thread. To maintain correct reference counting, the monitor unreference has been moved to virCHStartEventHandler (the child thread). Other monitor unreference in virCHStartEventHandler are retained for cases where new thread creation fails, as the reference in not used afterward. VM Reference Counting Fix: The VM object was being unreferenced in virCHEventHandlerLoop while it was still being used by the debug print. To resolve this, the VM unreference has been moved to after the debug print. Signed-off-by: Kirill Shchetiniuk --- src/ch/ch_events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 1cce30836a..2dd3e7ecc2 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -287,8 +287,9 @@ virCHEventHandlerLoop(void *data) } =20 g_clear_pointer(&mon->event_buffer.buffer, g_free); - virObjectUnref(vm); VIR_DEBUG("%s: Event handler loop thread exiting", vm->def->name); + virObjectUnref(vm); + virObjectUnref(mon); return; } =20 @@ -308,7 +309,6 @@ virCHStartEventHandler(virCHMonitor *mon) virObjectUnref(mon); return -1; } - virObjectUnref(mon); =20 g_atomic_int_set(&mon->event_handler_stop, 0); return 0; --=20 2.48.1