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

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


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)]

This bug report was last modified 1 year and 10 days ago.

Previous Next


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