Subject: Re: bug#19774: 25.0.50; Emacs crashes when C-u <N> on a Gnus folder (reproducible)

From: Eli Zaretskii <[email-masked]>
Date: Thu, 19 Feb 2015 12:05:23 +0200

> From: Óscar Fuentes <[email-masked]>
> Cc: Sebastien Vauban <[email-masked]>,  [email-masked]
> Date: Wed, 18 Feb 2015 17:40:36 +0100
> 
> Eval this code on *scratch*:
> 
> (require 'key-chord)
> (key-chord-mode 1)
> (require 'guide-key)
> (key-chord-define-global "x1" 'delete-other-windows)
> (guide-key-mode 1)
> 
> Now press `C-u 1'. A message appears:
> 
> Error running timer `guide-key/polling-function': (wrong-type-argument
> sequencep #<EMACS BUG: INVALID DATATYPE (PVEC 0xffffffffffffffff) Save
> your buffers immediately and please report this bug>)

Thanks for the recipe.  The patch below seems to fix the problem for
me; does it solve it for you?

Sebastien, can you see if key-chord and other packages involved in
this report still do their job after the change?

diff --git a/src/keyboard.c b/src/keyboard.c
index 4f6a441..ab57553 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3034,6 +3034,7 @@ static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
       Lisp_Object keys;
       ptrdiff_t key_count;
       bool key_count_reset;
+      ptrdiff_t command_key_start;
       struct gcpro gcpro1;
       ptrdiff_t count = SPECPDL_INDEX ();
 
@@ -3057,6 +3058,7 @@ static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
       /* Save the this_command_keys status.  */
       key_count = this_command_key_count;
       key_count_reset = this_command_key_count_reset;
+      command_key_start = this_single_command_key_start;
 
       if (key_count > 0)
 	keys = Fcopy_sequence (this_command_keys);
@@ -3067,6 +3069,7 @@ static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
       /* Clear out this_command_keys.  */
       this_command_key_count = 0;
       this_command_key_count_reset = 0;
+      this_single_command_key_start = 0;
 
       /* Now wipe the echo area.  */
       if (!NILP (echo_area_buffer[0]))
@@ -3090,6 +3093,7 @@ static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
 	 and this_command_keys state.  */
       this_command_key_count = key_count;
       this_command_key_count_reset = key_count_reset;
+      this_single_command_key_start = command_key_start;
       if (key_count > 0)
 	this_command_keys = keys;