[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g
From: |
Eli Zaretskii |
Subject: |
bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g |
Date: |
Tue, 12 Feb 2019 19:25:20 +0200 |
> Date: Sun, 10 Feb 2019 18:42:40 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 34394@debbugs.gnu.org
>
> > src/emacs -Q -L path/to/company-mode -l company -l foo.el -f foo-test-bug
>
> Thanks, this reproduces the problem with 100% probability, and I'm
> looking into the problem.
I think I found the culprit. Please see if the patch below fixes the
problem, including the one you had in the real-life scenario and
environment.
diff --git a/src/keyboard.c b/src/keyboard.c
index 49c687f..f6550f7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -365,6 +365,7 @@ static Lisp_Object make_lispy_focus_out (Lisp_Object);
static bool help_char_p (Lisp_Object);
static void save_getcjmp (sys_jmp_buf);
static void restore_getcjmp (sys_jmp_buf);
+static void unwind_getcjmp (void *);
static Lisp_Object apply_modifiers (int, Lisp_Object);
static void restore_kboard_configuration (int);
static void handle_interrupt (bool);
@@ -2144,12 +2145,14 @@ read_event_from_main_queue (struct timespec *end_time,
return c;
/* Actually read a character, waiting if necessary. */
+ ptrdiff_t count = SPECPDL_INDEX ();
save_getcjmp (save_jump);
+ record_unwind_protect_ptr (unwind_getcjmp, &save_jump);
restore_getcjmp (local_getcjmp);
if (!end_time)
timer_start_idle ();
c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
- restore_getcjmp (save_jump);
+ unbind_to (count, Qnil);
if (! NILP (c) && (kb != current_kboard))
{
@@ -2638,10 +2641,12 @@ read_char (int commandflag, Lisp_Object map,
{
Lisp_Object tem0;
+ ptrdiff_t count = SPECPDL_INDEX ();
save_getcjmp (save_jump);
+ record_unwind_protect_ptr (unwind_getcjmp, &save_jump);
restore_getcjmp (local_getcjmp);
tem0 = sit_for (Vecho_keystrokes, 1, 1);
- restore_getcjmp (save_jump);
+ unbind_to (count, Qnil);
if (EQ (tem0, Qt)
&& ! CONSP (Vunread_command_events))
echo_now ();
@@ -2712,10 +2717,12 @@ read_char (int commandflag, Lisp_Object map,
timeout = min (timeout, MOST_POSITIVE_FIXNUM / delay_level * 4);
timeout = delay_level * timeout / 4;
+ ptrdiff_t count1 = SPECPDL_INDEX ();
save_getcjmp (save_jump);
+ record_unwind_protect_ptr (unwind_getcjmp, &save_jump);
restore_getcjmp (local_getcjmp);
tem0 = sit_for (make_number (timeout), 1, 1);
- restore_getcjmp (save_jump);
+ unbind_to (count1, Qnil);
if (EQ (tem0, Qt)
&& ! CONSP (Vunread_command_events))
@@ -3329,6 +3336,14 @@ restore_getcjmp (sys_jmp_buf temp)
{
memcpy (getcjmp, temp, sizeof getcjmp);
}
+
+static void
+unwind_getcjmp (void *ptr)
+{
+ sys_jmp_buf jbuf;
+ memcpy (jbuf, *(sys_jmp_buf *)ptr, sizeof getcjmp);
+ restore_getcjmp (jbuf);
+}
/* Low level keyboard/mouse input.
kbd_buffer_store_event places events in kbd_buffer, and
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, (continued)
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/10
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g,
Eli Zaretskii <=
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/12
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/12
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/12
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/12
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/13
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/18
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/18
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, Eli Zaretskii, 2019/02/09
- bug#34394: 27.0.50; Emacs segfaults with SLY, company and C-g, João Távora, 2019/02/09