Subject: Re: bug#47067: 28.0.50; [feature/native-comp] Crash while scrolling through dispnew.c

From: Eli Zaretskii <[email-masked]>
Date: Sat, 13 Mar 2021 21:43:43 +0200

> From: Pip Cet <[email-masked]>
> Date: Sat, 13 Mar 2021 18:55:37 +0000
> Cc: Andrea Corallo <[email-masked]>, [email-masked]
> 
> Sure! Put the defun in a file called breakage.el. Then open emacs -Q
> in GDB and evaluate
> 
> (require 'comp)
> (let ((comp-debug 3) (comp-verbose 3))
>   (load (native-compile "breakage.el")))
> 
> Then set a GDB breakpoint on
> F632d626567696e6e696e672d6f662d73746174656d656e742d31_c_beginning_of_statement_1_0,
> continue and evaluate
> 
> (c-beginning-of-stmt-1)
> 
> In GDB, you should now see the "source" code interspersed with the
> disassembly (if you have that enabled).
> 
> I'd suggest to try disass/rs next and post the entire output, but you
> know your way around gdb much better than I do :-)
> 
> The code you're looking for looks like this:
> 
> 7961      /* calling subr: < */
> 7962      frame[(int)0] = freloc->R3c__0 ((long long)2, (&frame[(int)0]));
>    0x00007fffec660f41 <+3409>:    4c 89 f6    mov    %r14,%rsi
>    0x00007fffec660f44 <+3412>:    bf 02 00 00 00    mov    $0x2,%edi

Thanks, will try that some day.  This week's cup is full with
frustration already.

Btw, could there be a stack alignment issue?  When GDB cannot report a
full backtrace, I see:

  Thread 1 hit Breakpoint 4, Fskip_chars_backward (
      string=XIL(0x800000000696bf28), lim=XIL(0)) at syntax.c:1610
  1610      return skip_chars (0, string, lim, 1);
  (gdb) bt
  #0  Fskip_chars_backward (string=XIL(0x800000000696bf28), lim=XIL(0))
      at syntax.c:1610
  #1  0x09d8d5b2 in ?? ()
  #2  0x012608fa in funcall_subr (subr=0x765a848, numargs=0, args=0x828d20)
      at eval.c:3093
  #3  0x0126035f in Ffuncall (nargs=1, args=0x828d18) at eval.c:3016
  #4  0x7088e5ff in F632d666f6e742d6c6f636b2d636f6d706c65782d6465636c2d70726570617265_c_font_lock_complex_decl_prepare_0 ()
     from d:\usr\eli\.emacs.d\eln-cache\28.0.50-7d88f6c1\cc-fonts-d7d8a7f5-b7c359cd.eln
  #5  0x01261aa5 in funcall_lambda (fun=XIL(0xa000000007789a90), nargs=1,
      arg_vector=0x8290a0) at eval.c:3303
  #6  0x012603fa in Ffuncall (nargs=2, args=0x829098) at eval.c:3023
  #7  0x068daf93 in ?? ()
  #8  0x012dea48 in helper_save_restriction () at comp.c:4575
  #9  0x0122eb86 in wrong_type_argument (predicate=XIL(0x892404890c245c89),
      value=XIL(0x8244c89e45d8be0)) at data.c:143
  Backtrace stopped: previous frame inner to this frame (corrupt stack?)
  (gdb) fr 9
  #9  0x0122eb86 in wrong_type_argument (predicate=XIL(0x892404890c245c89),
      value=XIL(0x8244c89e45d8be0)) at data.c:143
  143       xsignal2 (Qwrong_type_argument, predicate, value);
  (gdb) p/x $ebp
  $7 = 0x122eaf2
  (gdb) down
  #8  0x012dea48 in helper_save_restriction () at comp.c:4575
  4575    }
  (gdb) p/x $ebp
  $8 = 0x122eaf2

The EBP values are not 8-byte aligned.  They aren't even 4-byte
aligned, which I don't understand how can happen on 32-bit x86
architecture.