GNU bug report logs - #70352
29.3.50; emacs-pgtk: possible leak of virtual memory

Previous Next

Package: emacs;

Reported by: Yang Yingchao <yang.yingchao <at> qq.com>

Date: Fri, 12 Apr 2024 11:13:04 UTC

Severity: normal

Found in version 29.3.50

To reply to this bug, email your comments to 70352 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Fri, 12 Apr 2024 11:13:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yang Yingchao <yang.yingchao <at> qq.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 Apr 2024 11:13:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: bug-gnu-emacs <at> gnu.org,Yang Yingchao <yang.yingchao <at> qq.com>
Subject: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Fri, 12 Apr 2024 18:56:17 +0800

I'm testing Emacs built with Pgtk (with GTK-4.12.5), and I suspect there
may be a memory leak in virtual memory.


Steps to reproduce:

1. Start Emacs with "-Q --bg-daemon=mytest".
2. Connect to the server with 'emacsclient -c -s mytest'. This will create a new frame.
3. Kill the newly created frame with `\C-x\C-c`.
4. Repeat steps 2 & 3, and observe `/proc/pid_of_emacs/maps`.

It seems like there could be a memory leak issue causing the increasing
number of "/memfd:gdk-wayland" entries and ultimately leading to the
crash without a core dump.


Some of my statistics are as follows:


# yyc <at> tbook in /proc/400602  [18:40:36]
$ cat maps | grep memfd | awk '{print $1}' | awk -F "-" '{sum=strtonum("0x"$2)-strtonum("0x"$1); print sum}' | awk '{sum+=$1} END {print sum}'
42688512
# yyc <at> tbook in /proc/400602  [18:40:57]
$ cat maps | grep memfd | awk '{print $1}' | awk -F "-" '{sum=strtonum("0x"$2)-strtonum("0x"$1); print sum}' | awk '{sum+=$1} END {print sum}'
51888128
# yyc <at> tbook in /proc/400602  [18:41:26]
$ cat /proc/400602/maps| grep /memfd: | wc -l
7
# yyc <at> tbook in /proc/400602  [18:41:41]
$ cat /proc/400602/maps| grep /memfd: | wc -l
9
# yyc <at> tbook in /proc/400602  [18:41:46]
$ cat /proc/400602/maps| grep /memfd: | wc -l
10
# yyc <at> tbook in /proc/400602  [18:41:51]
$ cat /proc/400602/maps| grep /memfd: | wc -l
10
# yyc <at> tbook in /proc/400602  [18:41:56]
$ cat /proc/400602/maps| grep /memfd: | wc -l
12
# yyc <at> tbook in /proc/400602  [18:42:01]
$ cat /proc/400602/maps| grep /memfd: | wc -l
12
# yyc <at> tbook in /proc/400602  [18:42:03]
$ cat /proc/400602/maps| grep /memfd:
7f0ca170a000-7f0ca1fd0000 rw-s 00000000 00:01 169719                     /memfd:gdk-wayland (deleted)
7f0ca1fd0000-7f0ca2896000 rw-s 00000000 00:01 169718                     /memfd:gdk-wayland (deleted)
7f0ca2896000-7f0ca315c000 rw-s 00000000 00:01 175557                     /memfd:gdk-wayland (deleted)
7f0ca315c000-7f0ca3a22000 rw-s 00000000 00:01 169709                     /memfd:gdk-wayland (deleted)
7f0ca3a22000-7f0ca42e8000 rw-s 00000000 00:01 169708                     /memfd:gdk-wayland (deleted)
7f0ca42e8000-7f0ca4bae000 rw-s 00000000 00:01 177320                     /memfd:gdk-wayland (deleted)
7f0ca4bae000-7f0ca5474000 rw-s 00000000 00:01 176334                     /memfd:gdk-wayland (deleted)
7f0ca5474000-7f0ca5d3a000 rw-s 00000000 00:01 175525                     /memfd:gdk-wayland (deleted)
7f0ca5d3a000-7f0ca6600000 rw-s 00000000 00:01 175517                     /memfd:gdk-wayland (deleted)
7f0ca773a000-7f0ca8000000 rw-s 00000000 00:01 175524                     /memfd:gdk-wayland (deleted)
7f0cc4381000-7f0cc47ff000 rw-s 00000000 00:01 175518                     /memfd:wayland-cursor (deleted)
7f0cc66da000-7f0cc67fa000 rw-s 00000000 00:01 175514                     /memfd:wayland-cursor (deleted)


Regards
yang





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sat, 13 Apr 2024 01:57:04 GMT) Full text and rfc822 format available.

Message #8 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Yang Yingchao <yang.yingchao <at> qq.com>
Cc: 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sat, 13 Apr 2024 09:55:49 +0800
Yang Yingchao <yang.yingchao <at> qq.com> writes:

> I'm testing Emacs built with Pgtk (with GTK-4.12.5), and I suspect there

The GTK 4 version of the PGTK port was a failed experiment of mine that
I quickly concluded was not feasible to continue maintaining, and is now
effectively abandoned.  It goes without saying that one shouldn't expect
to receive support for it on this list.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sat, 13 Apr 2024 07:16:04 GMT) Full text and rfc822 format available.

Message #11 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: yang.yingchao <at> qq.com, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sat, 13 Apr 2024 10:15:08 +0300
> Cc: 70352 <at> debbugs.gnu.org
> Date: Sat, 13 Apr 2024 09:55:49 +0800
> From:  Po Lu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Yang Yingchao <yang.yingchao <at> qq.com> writes:
> 
> > I'm testing Emacs built with Pgtk (with GTK-4.12.5), and I suspect there
> 
> The GTK 4 version of the PGTK port was a failed experiment of mine that
> I quickly concluded was not feasible to continue maintaining, and is now
> effectively abandoned.  It goes without saying that one shouldn't expect
> to receive support for it on this list.

Can we display a prominent warning to that effect when Emacs is
configured for PGTK to be built with GTK4?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sat, 13 Apr 2024 11:01:02 GMT) Full text and rfc822 format available.

Message #14 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yang.yingchao <at> qq.com, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sat, 13 Apr 2024 18:59:49 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: 70352 <at> debbugs.gnu.org
>> Date: Sat, 13 Apr 2024 09:55:49 +0800
>> From:  Po Lu via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> Yang Yingchao <yang.yingchao <at> qq.com> writes:
>> 
>> > I'm testing Emacs built with Pgtk (with GTK-4.12.5), and I suspect there
>> 
>> The GTK 4 version of the PGTK port was a failed experiment of mine that
>> I quickly concluded was not feasible to continue maintaining, and is now
>> effectively abandoned.  It goes without saying that one shouldn't expect
>> to receive support for it on this list.
>
> Can we display a prominent warning to that effect when Emacs is
> configured for PGTK to be built with GTK4?

It's really not "we", just "I"--the code implementing such a
configuration doesn't exist in the Emacs repository on Savannah...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sat, 13 Apr 2024 12:03:03 GMT) Full text and rfc822 format available.

Message #17 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: yang.yingchao <at> qq.com, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sat, 13 Apr 2024 15:02:03 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: yang.yingchao <at> qq.com,  70352 <at> debbugs.gnu.org
> Date: Sat, 13 Apr 2024 18:59:49 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Cc: 70352 <at> debbugs.gnu.org
> >> Date: Sat, 13 Apr 2024 09:55:49 +0800
> >> From:  Po Lu via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> >> 
> >> Yang Yingchao <yang.yingchao <at> qq.com> writes:
> >> 
> >> > I'm testing Emacs built with Pgtk (with GTK-4.12.5), and I suspect there
> >> 
> >> The GTK 4 version of the PGTK port was a failed experiment of mine that
> >> I quickly concluded was not feasible to continue maintaining, and is now
> >> effectively abandoned.  It goes without saying that one shouldn't expect
> >> to receive support for it on this list.
> >
> > Can we display a prominent warning to that effect when Emacs is
> > configured for PGTK to be built with GTK4?
> 
> It's really not "we", just "I"--the code implementing such a
> configuration doesn't exist in the Emacs repository on Savannah...

Maybe I'm confused, but if this code is not in Emacs, how come the OP
bumped into this problem in the first place?  What am I missing?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 00:13:04 GMT) Full text and rfc822 format available.

Message #20 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Björn Bidar <bjorn.bidar <at> thaodan.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, yang.yingchao <at> qq.com, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 03:11:44 +0300
Eli Zaretskii <eliz <at> gnu.org> writes:

>> > configured for PGTK to be built with GTK4?
>> 
>> It's really not "we", just "I"--the code implementing such a
>> configuration doesn't exist in the Emacs repository on Savannah...
>
> Maybe I'm confused, but if this code is not in Emacs, how come the OP
> bumped into this problem in the first place?  What am I missing?

maybe confused the gtk version Emacs was built with?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 01:01:02 GMT) Full text and rfc822 format available.

Message #23 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Björn Bidar <bjorn.bidar <at> thaodan.de>
Cc: yang.yingchao <at> qq.com, Eli Zaretskii <eliz <at> gnu.org>, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 08:59:30 +0800
Björn Bidar <bjorn.bidar <at> thaodan.de> writes:

>> Maybe I'm confused, but if this code is not in Emacs, how come the OP
>> bumped into this problem in the first place?  What am I missing?
>
> maybe confused the gtk version Emacs was built with?

Perhaps, but let's wait for a response from OP.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 03:07:02 GMT) Full text and rfc822 format available.

Message #26 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Björn Bidar <bjorn.bidar <at> thaodan.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, yang.yingchao <at> qq.com, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 06:05:54 +0300
It's not possible to built Emacs with GTK4 unless forcing to use GTK4
as GTK is versioned. Emacs requests GTK3/GTK2 during build nothing else,
but I might be wrong that's why I guessed it had maybe be picked up by
accident.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 05:49:03 GMT) Full text and rfc822 format available.

Message #29 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: yang.yingchao <at> qq.com, bjorn.bidar <at> thaodan.de, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 08:48:09 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  yang.yingchao <at> qq.com,  70352 <at> debbugs.gnu.org
> Date: Sun, 14 Apr 2024 08:59:30 +0800
> 
> Björn Bidar <bjorn.bidar <at> thaodan.de> writes:
> 
> >> Maybe I'm confused, but if this code is not in Emacs, how come the OP
> >> bumped into this problem in the first place?  What am I missing?
> >
> > maybe confused the gtk version Emacs was built with?
> 
> Perhaps, but let's wait for a response from OP.

I thought the question I asked was for you to answer, not for the OP:
how come the OP bumped into a problem that (AFAIU) could only happen
when using code that is not in the Emacs Git repository?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 06:30:04 GMT) Full text and rfc822 format available.

Message #32 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yang.yingchao <at> qq.com, bjorn.bidar <at> thaodan.de, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 14:28:33 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> I thought the question I asked was for you to answer, not for the OP:
> how come the OP bumped into a problem that (AFAIU) could only happen
> when using code that is not in the Emacs Git repository?

Because the OP, presumably, built code that I published elsewhere (and,
I had hoped, discreetly enough to avoid the attention of casual Emacs
users).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sun, 14 Apr 2024 07:33:04 GMT) Full text and rfc822 format available.

Message #35 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: yang.yingchao <at> qq.com, bjorn.bidar <at> thaodan.de, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Sun, 14 Apr 2024 10:31:57 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: bjorn.bidar <at> thaodan.de,  yang.yingchao <at> qq.com,  70352 <at> debbugs.gnu.org
> Date: Sun, 14 Apr 2024 14:28:33 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > I thought the question I asked was for you to answer, not for the OP:
> > how come the OP bumped into a problem that (AFAIU) could only happen
> > when using code that is not in the Emacs Git repository?
> 
> Because the OP, presumably, built code that I published elsewhere (and,
> I had hoped, discreetly enough to avoid the attention of casual Emacs
> users).

If that's what happened, then yes, it explains everything (and means
we don't need to discuss this issue anymore).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Mon, 15 Apr 2024 01:38:04 GMT) Full text and rfc822 format available.

Message #38 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: 70352 <at> debbugs.gnu.org
Subject: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual
 memory
Date: Mon, 15 Apr 2024 09:36:50 +0800
[Message part 1 (text/plain, inline)]
-------------------- Start of forwarded message --------------------
From: Yang Yingchao <yang.yingchao <at> qq.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
Date: Mon, 15 Apr 2024 09:21:04 +0800

[Message part 2 (text/plain, inline)]
Hi * Eli*,

On Sun, Apr 14 2024, Eli Zaretskii wrote:

>> From: Po Lu <luangruo <at> yahoo.com>
>> Cc: bjorn.bidar <at> thaodan.de,  yang.yingchao <at> qq.com,  70352 <at> debbugs.gnu.org
>> Date: Sun, 14 Apr 2024 14:28:33 +0800
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> > I thought the question I asked was for you to answer, not for the OP:
>> > how come the OP bumped into a problem that (AFAIU) could only happen
>> > when using code that is not in the Emacs Git repository?
>>
>> Because the OP, presumably, built code that I published elsewhere (and,
>> I had hoped, discreetly enough to avoid the attention of casual Emacs
>> users).
>
> If that's what happened, then yes, it explains everything (and means
> we don't need to discuss this issue anymore).


Sorry for the late response.

And actually, I was wrong about the GTK version. I mistook the GTK version as the GTK+ version...

Here is the actual version related to GTK+:

```

$ ldd emacs | grep gtk
        libgtk-3.so.0 => /usr/lib64/libgtk-3.so.0 (0x00007f1e4ba00000)
```

If any other information is required, please let me know.

Regards,

-- *Yang Yingchao*
-------------------- End of forwarded message --------------------

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Mon, 15 Apr 2024 01:59:03 GMT) Full text and rfc822 format available.

Message #41 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: 70352 <at> debbugs.gnu.org
Subject: Re: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of
 virtual memory
Date: Mon, 15 Apr 2024 09:58:03 +0800
On Mon, Apr 15 2024, Yang Yingchao wrote:

> -------------------- Start of forwarded message --------------------
> From: Yang Yingchao <yang.yingchao <at> qq.com>
> To: Eli Zaretskii <eliz <at> gnu.org>
> Subject: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of virtual memory
> Date: Mon, 15 Apr 2024 09:21:04 +0800
>
> <#multipart type=mixed>
> <#part type="text/plain" disposition=inline>
> Hi * Eli*,
>
> On Sun, Apr 14 2024, Eli Zaretskii wrote:
>
>>> From: Po Lu <luangruo <at> yahoo.com>
>>> Cc: bjorn.bidar <at> thaodan.de,  yang.yingchao <at> qq.com,  70352 <at> debbugs.gnu.org
>>> Date: Sun, 14 Apr 2024 14:28:33 +0800
>>>
>>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>>
>>> > I thought the question I asked was for you to answer, not for the OP:
>>> > how come the OP bumped into a problem that (AFAIU) could only happen
>>> > when using code that is not in the Emacs Git repository?
>>>
>>> Because the OP, presumably, built code that I published elsewhere (and,
>>> I had hoped, discreetly enough to avoid the attention of casual Emacs
>>> users).
>>
>> If that's what happened, then yes, it explains everything (and means
>> we don't need to discuss this issue anymore).
>
>
> Sorry for the late response.
>
> And actually, I was wrong about the GTK version. I mistook the GTK version as the GTK+ version...
>
> Here is the actual version related to GTK+:
>
> ```
>
> $ ldd emacs | grep gtk
>         libgtk-3.so.0 => /usr/lib64/libgtk-3.so.0 (0x00007f1e4ba00000)
> ```
>
> If any other information is required, please let me know.
>
> Regards,
>
> -- *Yang Yingchao*
> -------------------- End of forwarded message --------------------
> <#/part>
> <#/multipart>

FYI:
I tested this in two window managers (Hyprland & Sway), and found that the same issue exists.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Wed, 17 Apr 2024 07:32:01 GMT) Full text and rfc822 format available.

Message #44 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: 70352 <at> debbugs.gnu.org
Subject: Re: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible leak of
 virtual memory
Date: Wed, 17 Apr 2024 15:30:11 +0800
On Mon, Apr 15 2024, Yang Yingchao wrote:

>
> FYI:
> I tested this in two window managers (Hyprland & Sway), and found that the same issue exists.


I'm not familiar with the GTK toolkit, but it seems that the creation
and destruction of surfaces are not properly paired.


I added breakpoints to `_gdk_wayland_display_create_shm_surface()` and
`gdk_wayland_cairo_surface_destroy()`, then executed steps 2 and 3. I
found that `_gdk_wayland_display_create_shm_surface()` is called 3
times, but `gdk_wayland_cairo_surface_destroy()` is only called 2 times.

I'm not sure if this is related...

```
70:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
125:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2d87c2a0)
137:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
153:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
181:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2e33fc40)
```





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Sat, 27 Apr 2024 08:33:12 GMT) Full text and rfc822 format available.

Message #47 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yang Yingchao <yang.yingchao <at> qq.com>, Po Lu <luangruo <at> yahoo.com>
Cc: 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: Fwd: Re: bug#70352: 29.3.50;
 emacs-pgtk: possible leak of virtual memory
Date: Sat, 27 Apr 2024 11:32:05 +0300
> Date: Wed, 17 Apr 2024 15:30:11 +0800
> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> On Mon, Apr 15 2024, Yang Yingchao wrote:
> 
> >
> > FYI:
> > I tested this in two window managers (Hyprland & Sway), and found that the same issue exists.
> 
> 
> I'm not familiar with the GTK toolkit, but it seems that the creation
> and destruction of surfaces are not properly paired.
> 
> 
> I added breakpoints to `_gdk_wayland_display_create_shm_surface()` and
> `gdk_wayland_cairo_surface_destroy()`, then executed steps 2 and 3. I
> found that `_gdk_wayland_display_create_shm_surface()` is called 3
> times, but `gdk_wayland_cairo_surface_destroy()` is only called 2 times.
> 
> I'm not sure if this is related...
> 
> ```
> 70:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
> 125:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2d87c2a0)
> 137:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
> 153:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
> 181:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2e33fc40)
> ```

Po Lu, any comments or suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Mon, 29 Apr 2024 08:47:02 GMT) Full text and rfc822 format available.

Message #50 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Po Lu <luangruo <at> yahoo.com>, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible
 leak of virtual memory
Date: Mon, 29 Apr 2024 16:45:16 +0800
[Message part 1 (text/plain, inline)]
On Sat, Apr 27 2024, Eli Zaretskii wrote:

>> Date: Wed, 17 Apr 2024 15:30:11 +0800
>> From:  Yang Yingchao via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> On Mon, Apr 15 2024, Yang Yingchao wrote:
>> 
>> >
>> > FYI:
>> > I tested this in two window managers (Hyprland & Sway), and found that the same issue exists.
>> 
>> 
>> I'm not familiar with the GTK toolkit, but it seems that the creation
>> and destruction of surfaces are not properly paired.
>> 
>> 
>> I added breakpoints to `_gdk_wayland_display_create_shm_surface()` and
>> `gdk_wayland_cairo_surface_destroy()`, then executed steps 2 and 3. I
>> found that `_gdk_wayland_display_create_shm_surface()` is called 3
>> times, but `gdk_wayland_cairo_surface_destroy()` is only called 2 times.
>> 
>> I'm not sure if this is related...
>> 
>> ```
>> 70:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
>> 125:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2d87c2a0)
>> 137:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
>> 153:Thread 1 "emacs" hit Breakpoint 6, _gdk_wayland_display_create_shm_surface (display=<optimized out>,
>> 181:Thread 1 "emacs" hit Breakpoint 5, gdk_wayland_cairo_surface_destroy (p=0x555b2e33fc40)
>> ```
>
> Po Lu, any comments or suggestions?

Could this be an issue with gtk+? I made some changes to gtk+-3.24.41, and it seems like the issue has disappeared...

,----
| diff -urNa gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c
| --- gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c	2024-01-24 09:14:34.000000000 +0800
| +++ gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c	2024-04-29 16:41:00.691373426 +0800
| @@ -952,6 +952,11 @@
|    /* Release came in, we haven't done any interim updates, so we can just use
|     * the old committed buffer again.
|     */
| +
| +  if (impl->staging_cairo_surface) {
| +    g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
| +  }
| +
|    impl->staging_cairo_surface = g_steal_pointer (&impl->committed_cairo_surface);
|  }
`----

Actually, I do not understand the logic of the function `buffer_release_callback()', but when
debugging this issue with gdb, I noticed that the `impl->staging_cairo_surface' which was created via
`_gdk_wayland_display_create_shm_surface' was replaced by `impl->committed_cairo_surface' without
being released first.

Regards,

-- *Yang Yingchao*
[gtk+-3.24.41-virtual-memory-leak.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Mon, 29 Apr 2024 11:48:02 GMT) Full text and rfc822 format available.

Message #53 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Yang Yingchao <yang.yingchao <at> qq.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible
 leak of virtual memory
Date: Mon, 29 Apr 2024 19:46:39 +0800
Yang Yingchao <yang.yingchao <at> qq.com> writes:

> Could this be an issue with gtk+? I made some changes to gtk+-3.24.41,
> and it seems like the issue has disappeared...

I don't understand.  Aren't you building with GTK 4.x?

> ,----
> | diff -urNa gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c
> | --- gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c	2024-01-24 09:14:34.000000000 +0800
> | +++ gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c	2024-04-29 16:41:00.691373426 +0800
> | @@ -952,6 +952,11 @@
> |    /* Release came in, we haven't done any interim updates, so we can just use
> |     * the old committed buffer again.
> |     */
> | +
> | +  if (impl->staging_cairo_surface) {
> | +    g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
> | +  }
> | +
> |    impl->staging_cairo_surface = g_steal_pointer (&impl->committed_cairo_surface);
> |  }
> `----
>
> Actually, I do not understand the logic of the function
> `buffer_release_callback()', but when debugging this issue with gdb, I
> noticed that the `impl->staging_cairo_surface' which was created via
> `_gdk_wayland_display_create_shm_surface' was replaced by
> `impl->committed_cairo_surface' without being released first.

I'm afraid the GDK Wayland backend is outside my line of country.
Perhaps you ought to take this up with their developers, but be prepared
for weeks of frustration as they presume to tell you how your program
should bend over backwards to accommodate their misdesigns.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70352; Package emacs. (Mon, 29 Apr 2024 12:30:01 GMT) Full text and rfc822 format available.

Message #56 received at 70352 <at> debbugs.gnu.org (full text, mbox):

From: Yang Yingchao <yang.yingchao <at> qq.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 70352 <at> debbugs.gnu.org
Subject: Re: bug#70352: Fwd: Re: bug#70352: 29.3.50; emacs-pgtk: possible
 leak of virtual memory
Date: Mon, 29 Apr 2024 20:27:52 +0800
On Mon, Apr 29 2024, Po Lu wrote:

> Yang Yingchao <yang.yingchao <at> qq.com> writes:
>
>> Could this be an issue with gtk+? I made some changes to gtk+-3.24.41,
>> and it seems like the issue has disappeared...
>
> I don't understand.  Aren't you building with GTK 4.x?

No, I thought I was using GTK 4 initially, but I'm actually using GTK+ 3...


>
>> ,----
>> | diff -urNa gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c
>> | --- gtk+-3.24.41.orig/gdk/wayland/gdkwindow-wayland.c	2024-01-24 09:14:34.000000000 +0800
>> | +++ gtk+-3.24.41/gdk/wayland/gdkwindow-wayland.c	2024-04-29 16:41:00.691373426 +0800
>> | @@ -952,6 +952,11 @@
>> |    /* Release came in, we haven't done any interim updates, so we can just use
>> |     * the old committed buffer again.
>> |     */
>> | +
>> | +  if (impl->staging_cairo_surface) {
>> | +    g_clear_pointer (&impl->staging_cairo_surface, cairo_surface_destroy);
>> | +  }
>> | +
>> |    impl->staging_cairo_surface = g_steal_pointer (&impl->committed_cairo_surface);
>> |  }
>> `----
>>
>> Actually, I do not understand the logic of the function
>> `buffer_release_callback()', but when debugging this issue with gdb, I
>> noticed that the `impl->staging_cairo_surface' which was created via
>> `_gdk_wayland_display_create_shm_surface' was replaced by
>> `impl->committed_cairo_surface' without being released first.
>
> I'm afraid the GDK Wayland backend is outside my line of country.
> Perhaps you ought to take this up with their developers, but be prepared
> for weeks of frustration as they presume to tell you how your program
> should bend over backwards to accommodate their misdesigns.

Sure, I'll file a bug report there.

As a Gentoo user, I can patch the source code on my machine locally,
therefore, it would not be a real issue for me even if they don't fix it.


Thanks for your time.





This bug report was last modified 4 days ago.

Previous Next


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