GNU bug report logs - #76473
31.0.50; gnutls_pproc leak

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Helmut Eller <eller.helmut@HIDDEN>; Keywords: patch; dated Fri, 21 Feb 2025 15:18:03 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 76473 <at> debbugs.gnu.org:


Received: (at 76473) by debbugs.gnu.org; 21 Feb 2025 18:02:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 13:02:49 2025
Received: from localhost ([127.0.0.1]:35086 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlXMP-0001n7-K8
	for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 13:02:49 -0500
Received: from mail-10630.protonmail.ch ([79.135.106.30]:53323)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1tlXMM-0001lp-63
 for 76473 <at> debbugs.gnu.org; Fri, 21 Feb 2025 13:02:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1740160958; x=1740420158;
 bh=SbrOjOqXp+EpNSnvONyrFta8CG89DY1O+9DXelEH7j0=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
 b=b00hTraDQUY0FfvnmhnFmM7YNzQHmnrRur3KliZSLgsgt0Z1qTyRuzOMYMybM3aWR
 8Zp7tvsUn9NXXMqu6d5q+Cd7cErAZl6XRpgOj4KyaSelUxWn49Wrb6ZcpJi8Yh9KUL
 ykT0rBVADo095/9WQm5LC7f8W+NjAr39MuA7DCGyklmNC3RELXP4ZGcrkdJnbZ2tcr
 +0FyFI6n3PtneuSWOG+MGCroYkystOs69f+x/4Z3kEcZmcl1i6poaGmUdKNxiBGu2r
 4aCRFquERu9PRp7DAVpEmAYSgfzGYHfMDU76eCavnhnRK/Sh7JKKj6ginaw4lTLPoX
 84owO7As/Ra2g==
Date: Fri, 21 Feb 2025 18:02:34 +0000
To: Helmut Eller <eller.helmut@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#76473: 31.0.50; gnutls_pproc leak
Message-ID: <87msefrxb5.fsf@HIDDEN>
In-Reply-To: <87o6yv72g5.fsf@HIDDEN>
References: <87o6yv72g5.fsf@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 05cce54147b93ea1d38bd8eeedc3c2932d90e54e
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76473
Cc: 76473 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

"Helmut Eller" <eller.helmut@HIDDEN> writes:

> On the features/igc branch, it looks like the process->gnutls_pproc
> field is never freed.

AFAICT, on w32 (which is the only place where it's used), the
process->gnutls_pproc pointer will keep alive the process indefinitely,
so the entire process is never freed.  Right?

> This patch would fix that:

I believe it would!  Is anyone testing the w32/w64 + gnutls combination?

Pip





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76473; Package emacs. Full text available.
Added tag(s) patch. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Feb 2025 15:17:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 10:17:33 2025
Received: from localhost ([127.0.0.1]:60486 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlUmS-0006ar-Gd
	for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 10:17:33 -0500
Received: from lists.gnu.org ([209.51.188.17]:58178)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eller.helmut@HIDDEN>)
 id 1tlUmA-0006VI-3p
 for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 10:17:29 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eller.helmut@HIDDEN>)
 id 1tlUlu-00063M-9W
 for bug-gnu-emacs@HIDDEN; Fri, 21 Feb 2025 10:16:58 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <eller.helmut@HIDDEN>)
 id 1tlUlq-0004A3-IM
 for bug-gnu-emacs@HIDDEN; Fri, 21 Feb 2025 10:16:58 -0500
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-43948f77f1aso13830675e9.0
 for <bug-gnu-emacs@HIDDEN>; Fri, 21 Feb 2025 07:16:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740151012; x=1740755812; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Au+RR64eLeR7CvjipdDaT81m+Wdlmsu+2FJRk6yDvt4=;
 b=e09l7kJ3UsLy55OszLcFDh0qH9xDfk480Ku8zN4iiZ1VMtLvOPSYAefqYRnMj4If3k
 IMuwbpbvB0Fay/hA35EAPu9RWhthWxJH072GCiLsMHGFS7lh5/VXbOE+sMjXaZLS1JgE
 354ddPUODPlgd9lzgNUO2MgN6/k2Hsv0YngWoRwtQmi81/Ffu+n3VGCs5gJXpwhdMuG7
 XQwQTTVnE4XMT6Z6vKWABT3ko3YIyROdKAJh8udplol6oCPqfyS4yfuxtVAEep7JlX9k
 akdhNUOIUBjvQ42z2o6zjslEjeph4HqIsPBRhoocRjvwocpv9n/ADLUCTzY6ZK/5T7aS
 +1xA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740151012; x=1740755812;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Au+RR64eLeR7CvjipdDaT81m+Wdlmsu+2FJRk6yDvt4=;
 b=GSRDJ1v1ByHy8CvCp13DiZilnxmN5u1xGBCOmBSs+eJlVIHKE/K29+AW37mGTSlxXG
 z+s4kMdlcvgWYwUuiS9faJEACSHdo0Eadle/LE1qt/bEfU76Xyv09uS9J03Q9DO2yemd
 7jqvUbyGAlLS+DRoBhBHNPMEt7wxR4wuhjmu06YUlgpNcrlm+eksRhkQ201DDJGONAvg
 mI9bIIyE5CgFzHOcanbHWm6YZk0kVZuFxxUfVxklwqu0eD/rvV4rY2LDEPV4w0Hh78qK
 kXPrrgiI11Ll3HMneEKyWSmzx7/9PbA2Q2FIsTc3unkY0Br+rgICLPaPNpyxVEQFN1Co
 oJTA==
X-Gm-Message-State: AOJu0YwF5vVenCNImB5I1mpVvToywqRonTIerKilXHXGApOXh4WqD/dK
 xLrdg31il/GsrSpQ770y6NePcZlyQE8UCVH5aD4WifumXgR/cYuB0hGUJw==
X-Gm-Gg: ASbGnct7HkSiVQvY8pT49yZ5D0e0iHKSFF7dGpCH4GFeGiSafQeOR5B3pU11yNkfDQk
 clr56rBwvzVeTJ/+/X7ApDZJzkBQAEUUTFv1qAReSUSn0GouvI+Bq3rBIAfwC+Xp5bB0HjCMWzq
 L6mAZHUbWhzSXLjWK9scxkim9f8Gwx8CxBhNCzIRvK4cZbyPHlpWANDTAv1ETB8eed5hmG/sjkp
 FWwFEBj76I2fvbx4TH7cbCRU+1hDLbhlnkMbpy3JfIGoYWMD/j8hrvO5HDpPfw5CR/i6ZRsoH4U
 id+rWJoWHS/yXKs/Y9jCQgxZ6qI7ibGg7pw/0RbrGGd4MmJwe5pVoXbP7U8=
X-Google-Smtp-Source: AGHT+IGGxhc4vMq4+CT/iUGBix97O0dqZ7yf/wi81p5EVBYfAVy5xXMuU9a6LjVbA7g/5qq5WN7YHA==
X-Received: by 2002:a05:600c:1c1b:b0:439:942c:c1cd with SMTP id
 5b1f17b1804b1-439ae1f1991mr32037865e9.15.1740151011844; 
 Fri, 21 Feb 2025 07:16:51 -0800 (PST)
Received: from caladan (dialin-233080.rol.raiffeisen.net. [195.254.233.80])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-439b02d854csm20092955e9.15.2025.02.21.07.16.50
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 21 Feb 2025 07:16:50 -0800 (PST)
From: Helmut Eller <eller.helmut@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 31.0.50; gnutls_pproc leak
X-Debbugs-Cc: 
Date: Fri, 21 Feb 2025 16:16:42 +0100
Message-ID: <87o6yv72g5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::32f;
 envelope-from=eller.helmut@HIDDEN; helo=mail-wm1-x32f.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

On the features/igc branch, it looks like the process->gnutls_pproc
field is never freed.

This patch would fix that:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Don-t-forget-to-free-process-gnutls_pproc-if-we-HAVE.patch

From d13ef81273c45f60add3a7adbea8274a916f469a Mon Sep 17 00:00:00 2001
From: Helmut Eller <eller.helmut@HIDDEN>
Date: Fri, 21 Feb 2025 15:31:58 +0100
Subject: [PATCH] Don't forget to free process->gnutls_pproc if we HAVE_MPS.

* src/gnutls.c (emacs_gnutls_deinit): Free gnutls_pproc here.
* src/alloc.c (cleanup_vector): Not here.
---
 src/alloc.c  |  7 +------
 src/gnutls.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 7e74fd53335..74e85a9962b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3450,12 +3450,6 @@ cleanup_vector (struct Lisp_Vector *vector)
 	hash_table_allocated_bytes -= bytes;
       }
       break;
-    case PVEC_PROCESS:
-      {
-	struct Lisp_Process *p = PSEUDOVEC_STRUCT (vector, Lisp_Process);
-	xfree (p->gnutls_pproc);
-      }
-      break;
     /* Keep the switch exhaustive.  */
     case PVEC_NORMAL_VECTOR:
     case PVEC_FREE:
@@ -3465,6 +3459,7 @@ cleanup_vector (struct Lisp_Vector *vector)
     case PVEC_WINDOW:
     case PVEC_BOOL_VECTOR:
     case PVEC_BUFFER:
+    case PVEC_PROCESS:
     case PVEC_TERMINAL:
     case PVEC_WINDOW_CONFIGURATION:
     case PVEC_OTHER:
diff --git a/src/gnutls.c b/src/gnutls.c
index 50c6bc67e33..7eaf01f6b6e 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -985,6 +985,17 @@ emacs_gnutls_deinit (Lisp_Object proc)
   if (XPROCESS (proc)->gnutls_certificates)
     gnutls_deinit_certificates (XPROCESS (proc));
 
+  struct Lisp_Process *p = XPROCESS (proc);
+  if (p->gnutls_pproc)
+    {
+#ifdef HAVE_MPS
+      igc_xfree (p->gnutls_pproc);
+#else
+      xfree (p->gnutls_pproc);
+#endif
+      p->gnutls_pproc = NULL;
+    }
+
   XPROCESS (proc)->gnutls_p = false;
   return Qt;
 }
-- 
2.39.5


--=-=-=
Content-Type: text/plain


Helmut



In GNU Emacs 31.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.16.0) of 2025-02-21 built on caladan
Repository revision: d13ef81273c45f60add3a7adbea8274a916f469a
Repository branch: fix-gnutls-leak
Windowing system distributor 'The X.Org Foundation', version 11.0.12401004
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --config-cache --enable-checking=all,igc_check_fwd,igc_debug
 --with-mps=debug --with-xpm=ifavailable --with-gif=ifavailable
 --with-native-compilation=no 'CFLAGS=-g -O0 --std=gnu99
 -I/scratch/emacs/mps-install/include -L/scratch/emacs/mps-install/lib''

Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX
LIBSYSTEMD LIBXML2 MODULES MPS NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND
SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM
XINERAMA XINPUT2 XRANDR GTK3 ZLIB


--=-=-=--




Acknowledgement sent to Helmut Eller <eller.helmut@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#76473; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 21 Feb 2025 18:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.