unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Trevor Bentley <trevor@trevorbentley.com>
Cc: fweimer@redhat.com, 43389@debbugs.gnu.org, dj@redhat.com,
	bugs@gnu.support, carlos@redhat.com, michael_heerdegen@web.de
Subject: bug#43389: 28.0.50; Emacs memory leaks using hard disk all time
Date: Wed, 20 Jan 2021 09:53:08 -0500	[thread overview]
Message-ID: <jwvturb65pi.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87k0s7q0j4.fsf@mail.trevorbentley.com> (Trevor Bentley's message of "Wed, 20 Jan 2021 13:02:23 +0100")

> If you have a look at this long backtrace, you can see that we are inside
> a garbage_collect call (frame #38).  An X11 focus event comes in, triggering
> a bunch of GTK/GDK/X calls.  Mysteriously, this leads to a maybe_quit() call
> which in turn calls longjmp(). longjmp jumps right out of the garbage
> collect, leaving it unfinished.

Indeed, thanks!

> I don't know emacs internals, so you'll have to figure out if this is
> X dependent (probably) and/or GTK dependent.  It should be possible to come
> up with an easier way to reproduce it now.

The backtrace is clear enough, no need to reproduce it.

The GC properly speaking is actually finished at that point, BTW
(luckily: I think you'd have seen worse outcomes if that weren't the
case ;-).

I installed the simple patch below into `master.  It should fix the
immediate problem of failing to set consing_until_gc back to a sane
value and it should also fix the other immediate problem of getting to
`siglongjmp` from `unblock_input` via `window_parameter`.

Eli, do you think it should go to `emacs-27`?

> Backtrace:
> -----------
> (gdb) bt
> #0  0x00007ffff5571230 in siglongjmp () at /usr/lib/libc.so.6
> #1  0x00005555557bd38d in unwind_to_catch (catch=0x555555dfc320, type=NONLOCAL_EXIT_THROW, value=0x30) at eval.c:1181
> #2  0x00005555557bd427 in Fthrow (tag=0xe75830, value=0x30) at eval.c:1198
> #3  0x00005555557bdea7 in process_quit_flag () at eval.c:1526
> #4  0x00005555557bdeef in maybe_quit () at eval.c:1547
> #5  0x00005555557cbbb1 in Fassq (key=0xd0b0, alist=0x55555901c573) at fns.c:1609
> #6 0x0000555555632b63 in window_parameter (w=0x555555f2d088, parameter=0xd0b0) at window.c:2262
> #7 0x000055555563a075 in window_wants_tab_line (w=0x555555f2d088) at window.c:5410
> #8 0x00005555555c22b1 in get_phys_cursor_geometry (w=0x555555f2d088, row=0x55555d9f3ef0, glyph=0x55555fd20e00, xp=0x7fffffff9c48, yp=0x7fffffff9c4c, heightp=0x7fffffff9c50) at xdisp.c:2650
> #9 0x00005555556c1b12 in x_draw_hollow_cursor (w=0x555555f2d088, row=0x55555d9f3ef0) at xterm.c:9495
> #10 0x00005555556c24f9 in x_draw_window_cursor (w=0x555555f2d088, glyph_row=0x55555d9f3ef0, x=32, y=678, cursor_type=HOLLOW_BOX_CURSOR, cursor_width=1, on_p=true, active_p=false) at xterm.c:9682
> #11 0x000055555561a922 in display_and_set_cursor (w=0x555555f2d088, on=true, hpos=2, vpos=18, x=32, y=678) at xdisp.c:31738
> #12 0x000055555561aa5b in update_window_cursor (w=0x555555f2d088, on=true) at xdisp.c:31773
> #13 0x000055555561aabf in update_cursor_in_window_tree (w=0x555555f2d088, on_p=true) at xdisp.c:31791
> #14 0x000055555561aaab in update_cursor_in_window_tree (w=0x55555907a490, on_p=true) at xdisp.c:31789
> #15 0x000055555561aaab in update_cursor_in_window_tree (w=0x55555a514b68, on_p=true) at xdisp.c:31789
> #16 0x000055555561ab37 in gui_update_cursor (f=0x555556625468, on_p=true) at xdisp.c:31805
> #17 0x00005555556b9829 in x_frame_unhighlight (f=0x555556625468) at xterm.c:4490
> #18 0x00005555556ba22d in x_frame_rehighlight (dpyinfo=0x55555626d6c0) at xterm.c:4852
> #19 0x00005555556b98fc in x_new_focus_frame (dpyinfo=0x55555626d6c0, frame=0x0) at xterm.c:4520
> #20 0x00005555556b9a3d in x_focus_changed (type=10, state=2, dpyinfo=0x55555626d6c0, frame=0x555556625468, bufp=0x7fffffffa0d0) at xterm.c:4554
> #21 0x00005555556ba0a6 in x_detect_focus_change (dpyinfo=0x55555626d6c0, frame=0x555556625468, event=0x7fffffffa840, bufp=0x7fffffffa0d0) at xterm.c:4787
> #22 0x00005555556c0235 in handle_one_xevent (dpyinfo=0x55555626d6c0, event=0x7fffffffa840, finish=0x555555c901d4 <current_finish>, hold_quit=0x7fffffffab50) at xterm.c:8810
> #23 0x00005555556bde28 in event_handler_gdk (gxev=0x7fffffffa840, ev=0x55555cccf0c0, data=0x0) at xterm.c:7768
> #24 0x00007ffff75f780f in  () at /usr/lib/libgdk-3.so.0
> #25 0x00007ffff75fb3cb in  () at /usr/lib/libgdk-3.so.0
> #26 0x00007ffff759f15b in gdk_display_get_event () at /usr/lib/libgdk-3.so.0
> #27 0x00007ffff75fb104 in  () at /usr/lib/libgdk-3.so.0
> #28 0x00007ffff6fcb8f4 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
> #29 0x00007ffff701f821 in  () at /usr/lib/libglib-2.0.so.0
> #30 0x00007ffff6fca121 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
> #31 0x00007ffff784e2c7 in gtk_main_iteration () at /usr/lib/libgtk-3.so.0
> #32 0x00005555556c1821 in XTread_socket (terminal=0x5555560b7460, hold_quit=0x7fffffffab50) at xterm.c:9395
> #33 0x000055555570f3a2 in gobble_input () at keyboard.c:6890
> #34 0x000055555570f894 in handle_async_input () at keyboard.c:7121
> #35 0x000055555570f8dd in process_pending_signals () at keyboard.c:7139
> #36 0x000055555570f9cf in unblock_input_to (level=0) at keyboard.c:7162
> #37 0x000055555570fa4c in unblock_input () at keyboard.c:7187
> #38 0x000055555578f49a in garbage_collect () at alloc.c:6121
> #39 0x000055555578efe7 in maybe_garbage_collect () at alloc.c:5964
> #40 0x00005555557bb292 in maybe_gc () at lisp.h:5041
> #41 0x00005555557c12d6 in Ffuncall (nargs=2, args=0x7fffffffad68) at eval.c:2793
> #42 0x000055555580f7d6 in exec_byte_code
> ...  --------------

Of course, there might be other places where we could get to
`maybe_quit` from `XTread_socket`, given the enormous amount of code it
can execute.  :-(


        Stefan


diff --git a/src/alloc.c b/src/alloc.c
index c0a55e61b9..b86ed4ed26 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6101,11 +6101,13 @@ garbage_collect (void)
 
   gc_in_progress = 0;
 
-  unblock_input ();
-
   consing_until_gc = gc_threshold
     = consing_threshold (gc_cons_threshold, Vgc_cons_percentage, 0);
 
+  /* Unblock *after* re-setting `consing_until_gc` in case `unblock_input`
+     signals an error (see bug#43389).  */
+  unblock_input ();
+
   if (garbage_collection_messages && NILP (Vmemory_full))
     {
       if (message_p || minibuf_level > 0)
diff --git a/src/window.c b/src/window.c
index e025e0b082..eb16e2a433 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2260,7 +2260,7 @@ DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters,
 Lisp_Object
 window_parameter (struct window *w, Lisp_Object parameter)
 {
-  Lisp_Object result = Fassq (parameter, w->window_parameters);
+  Lisp_Object result = assq_no_quit (parameter, w->window_parameters);
 
   return CDR_SAFE (result);
 }






  parent reply	other threads:[~2021-01-20 14:53 UTC|newest]

Thread overview: 166+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 14:55 bug#44666: 28.0.50; malloc-info: Emacs became not responsive, using hard disk all time Jean Louis
2020-11-16 16:11 ` Eli Zaretskii
2020-11-16 16:17   ` Jean Louis
2020-11-17 15:04     ` Eli Zaretskii
2020-11-19  6:59       ` Jean Louis
2020-11-19 14:37         ` bug#43389: 28.0.50; Emacs memory leaks " Eli Zaretskii
2020-11-20  3:16           ` Jean Louis
2020-11-20  8:10             ` Eli Zaretskii
2020-11-22 19:52               ` Jean Louis
2020-11-22 20:16                 ` Eli Zaretskii
2020-11-23  3:41                   ` Carlos O'Donell
2020-11-23  8:11                   ` Jean Louis
2020-11-23  9:59                     ` Eli Zaretskii
2020-11-23 17:19                       ` Arthur Miller
2020-11-23 17:44                         ` Eli Zaretskii
2020-11-23 18:34                           ` Arthur Miller
2020-11-23 19:06                             ` Jean Louis
2020-11-23 19:15                             ` Eli Zaretskii
2020-11-23 19:49                               ` Arthur Miller
2020-11-23 20:04                                 ` Eli Zaretskii
2020-11-23 21:12                                   ` Arthur Miller
2020-11-24  2:07                                   ` Arthur Miller
2020-11-23 20:31                                 ` Jean Louis
2020-11-23 21:22                                   ` Arthur Miller
2020-11-24  5:29                                     ` Jean Louis
2020-11-24  8:15                                       ` Arthur Miller
2020-11-24  9:06                                         ` Jean Louis
2020-11-24  9:27                                           ` Arthur Miller
2020-11-24 17:18                                             ` Jean Louis
2020-11-25 14:59                                               ` Arthur Miller
2020-11-25 15:09                                                 ` Jean Louis
2020-11-23 13:27                   ` Jean Louis
2020-11-23 15:54                     ` Carlos O'Donell
2020-11-23 18:58                       ` Jean Louis
2020-11-23 19:34                         ` Eli Zaretskii
2020-11-23 19:49                           ` Jean Louis
2020-11-23 20:04                           ` Carlos O'Donell
2020-11-23 20:16                             ` Eli Zaretskii
2020-11-23 19:37                         ` Carlos O'Donell
2020-11-23 19:55                           ` Jean Louis
2020-11-23 20:06                             ` Carlos O'Donell
2020-11-23 20:18                               ` Jean Louis
2020-11-23 20:31                                 ` Eli Zaretskii
2020-11-23 20:41                                   ` Jean Louis
2020-11-23 20:53                                     ` Andreas Schwab
2020-11-23 21:09                                       ` Jean Louis
2020-11-24  3:25                                       ` Eli Zaretskii
2020-11-23 20:10                             ` Eli Zaretskii
2020-11-23 19:50                     ` Carlos O'Donell
2020-11-23 19:59                       ` Jean Louis
2020-11-23 10:59               ` Jean Louis
2020-11-23 15:46                 ` Eli Zaretskii
2020-11-23 17:29                   ` Arthur Miller
2020-11-23 17:45                     ` Eli Zaretskii
2020-11-23 18:40                       ` Arthur Miller
2020-11-23 19:23                         ` Eli Zaretskii
2020-11-23 19:38                           ` Arthur Miller
2020-11-23 19:52                             ` Eli Zaretskii
2020-11-23 20:03                               ` Arthur Miller
2020-11-23 19:39                           ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-23 19:59                             ` Arthur Miller
2020-11-23 20:15                               ` Eli Zaretskii
2020-11-23 21:15                                 ` Arthur Miller
2020-11-23 20:53                               ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-23 18:33                   ` Jean Louis
2020-11-23 21:30                   ` Trevor Bentley
2020-11-23 22:11                     ` Trevor Bentley
2020-11-24 16:07                     ` Eli Zaretskii
2020-11-24 19:05                       ` Trevor Bentley
2020-11-24 19:35                         ` Eli Zaretskii
2020-11-25 10:22                           ` Trevor Bentley
2020-11-25 17:47                             ` Eli Zaretskii
2020-11-25 19:06                               ` Trevor Bentley
2020-11-25 19:22                                 ` Eli Zaretskii
2020-11-25 19:38                                   ` Trevor Bentley
2020-11-25 20:02                                     ` Eli Zaretskii
2020-11-25 20:43                                       ` Trevor Bentley
2020-11-25 17:48                           ` Carlos O'Donell
2020-11-25 17:45                       ` Carlos O'Donell
2020-11-25 18:03                         ` Eli Zaretskii
2020-11-25 18:57                           ` Carlos O'Donell
2020-11-25 19:13                             ` Eli Zaretskii
2020-11-26  9:09                           ` Jean Louis
2020-11-26 14:13                             ` Eli Zaretskii
2020-11-26 18:37                               ` Jean Louis
2020-11-27  5:08                                 ` Carlos O'Donell
2020-11-25 18:08                         ` Jean Louis
2020-11-25 18:51                           ` Trevor Bentley
2020-11-25 19:02                             ` Carlos O'Donell
2020-11-25 19:17                               ` Trevor Bentley
2020-11-25 20:51                                 ` Carlos O'Donell
2020-11-26 13:58                                   ` Eli Zaretskii
2020-11-26 20:21                                     ` Carlos O'Donell
2020-11-26 20:30                                       ` Eli Zaretskii
2020-11-27  5:04                                         ` Carlos O'Donell
2020-11-27  7:40                                           ` Eli Zaretskii
2020-11-27  7:52                                             ` Eli Zaretskii
2020-11-27  8:20                                               ` Eli Zaretskii
2020-11-28  9:00                                                 ` Eli Zaretskii
2020-11-28 10:45                                                   ` Jean Louis
2020-11-28 17:49                                                   ` Trevor Bentley
2020-11-30 17:17                                                     ` Trevor Bentley
2020-11-30 18:15                                                       ` Eli Zaretskii
2020-11-30 18:33                                                         ` Trevor Bentley
2020-11-30 19:02                                                           ` Eli Zaretskii
2020-11-30 19:17                                                             ` Jean Louis
2020-12-01 10:14                                                               ` Trevor Bentley
2020-12-01 10:33                                                                 ` Jean Louis
2020-12-01 16:00                                                               ` Eli Zaretskii
2020-12-01 16:14                                                                 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-12-08 21:50                                                       ` Trevor Bentley
2020-12-08 22:12                                                         ` Carlos O'Donell
2020-12-10 18:45                                                         ` Eli Zaretskii
2020-12-10 19:21                                                           ` Stefan Monnier
2020-12-10 19:33                                                             ` Trevor Bentley
2020-12-10 19:47                                                               ` Stefan Monnier
2020-12-10 20:26                                                             ` Jean Louis
2020-12-10 20:30                                                             ` Jean Louis
2020-12-12 11:20                                                             ` Trevor Bentley
2020-12-12 11:40                                                               ` Eli Zaretskii
2020-12-12 19:14                                                                 ` Stefan Monnier
2020-12-12 19:20                                                                   ` Eli Zaretskii
2020-12-12 19:46                                                                     ` Stefan Monnier
2020-12-12 19:51                                                                       ` Eli Zaretskii
2020-12-12 20:14                                                                         ` Trevor Bentley
2020-12-12 22:16                                                                 ` Michael Heerdegen
2020-12-13  3:34                                                                   ` Eli Zaretskii
2020-12-13 10:20                                                                     ` Trevor Bentley
2020-12-13 15:30                                                                       ` Eli Zaretskii
2020-12-13 19:34                                                                         ` Trevor Bentley
2020-12-13 19:38                                                                           ` Eli Zaretskii
2020-12-13 19:59                                                                             ` Trevor Bentley
2020-12-13 20:21                                                                               ` Eli Zaretskii
2020-12-13 20:41                                                                                 ` Trevor Bentley
2020-12-14  3:24                                                                                   ` Eli Zaretskii
2020-12-14 21:24                                                                                     ` Trevor Bentley
2021-01-20 12:02                                                                                       ` Trevor Bentley
2021-01-20 12:08                                                                                         ` Trevor Bentley
2021-01-20 14:53                                                                                         ` Stefan Monnier [this message]
2021-01-20 15:32                                                                                           ` Eli Zaretskii
2021-01-20 15:40                                                                                             ` Stefan Monnier
2020-09-12  2:12                                                                                               ` bug#43395: 28.0.50; memory leak Madhu
2020-09-14 15:08                                                                                                 ` Eli Zaretskii
2020-09-15  1:23                                                                                                   ` Madhu
     [not found]                                                                                                 ` <handler.43395.D43389.161115724232582.notifdone@debbugs.gnu.org>
2021-02-06 16:25                                                                                                   ` bug#43389: bug#43395: closed Madhu
2021-03-21 14:10                                                                                                     ` Madhu
2021-01-20 15:49                                                                                               ` bug#43389: 28.0.50; Emacs memory leaks using hard disk all time Trevor Bentley
2020-12-10 20:24                                                           ` Jean Louis
2020-12-12  1:28                                                           ` Jean Louis
2020-12-12  8:49                                                             ` Andreas Schwab
2020-12-03  6:30                                                   ` Jean Louis
2020-11-28 17:31                                               ` Trevor Bentley
2020-11-27 15:33                                           ` Eli Zaretskii
2020-12-08 22:15                                             ` Carlos O'Donell
2020-11-25 19:01                           ` Carlos O'Donell
2020-11-26 12:37                         ` Trevor Bentley
2020-11-26 14:30                           ` Eli Zaretskii
2020-11-26 15:19                             ` Trevor Bentley
2020-11-26 15:31                               ` Eli Zaretskii
2020-11-27  4:54                               ` Carlos O'Donell
2020-11-27  8:44                                 ` Jean Louis
2020-11-26 18:25                             ` Jean Louis
2020-11-27  4:55                               ` Carlos O'Donell
2020-11-23  3:35             ` Carlos O'Donell
2020-11-23 11:07               ` Jean Louis
2020-11-19  7:43       ` bug#44666: 28.0.50; malloc-info: Emacs became not responsive, " Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvturb65pi.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=43389@debbugs.gnu.org \
    --cc=bugs@gnu.support \
    --cc=carlos@redhat.com \
    --cc=dj@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=michael_heerdegen@web.de \
    --cc=trevor@trevorbentley.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).