Subject: bug#57789: Emacs 28.1 clone build with native compilation crashes on s390x

From: Eli Zaretskii <[email-masked]>
Date: Sun, 18 Sep 2022 08:33:08 +0300

> From: Rob Browning <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> Date: Sat, 17 Sep 2022 16:04:31 -0500
> 
> Gerd Möllmann <[email-masked]> writes:
> 
> > Looking at Rob's backtrace, 
> >
> > #0  mark_object (arg=<optimized out>) at alloc.c:6809
> > #1  0x000002aa001a8ee6 in mark_objects (n=<optimized out>, obj=0x2aa00ac54a8) at alloc.c:6607
> > #2  mark_vectorlike (header=0x2aa00ac54a0) at alloc.c:6382
> > #3  0x000002aa001a8ee6 in mark_objects (n=<optimized out>, obj=0x2aa007f4ca8) at alloc.c:6607
> > #4  mark_vectorlike (header=0x2aa007f4ca0) at alloc.c:6382
> > #5  0x000002aa001a8ee6 in mark_objects (n=<optimized out>, obj=0x2aa007c3b10) at alloc.c:6607
> > #6  mark_vectorlike (header=0x2aa007c3b08) at alloc.c:6382
> > #7  0x000002aa001a7c3e in visit_static_gc_roots (visitor=...) at alloc.c:5926
> >
> > and seeing frame#7, would it be a way forward to determine which
> > staticpro (I assume it is a staticpro) that is?  Maybe that can give a
> > clue which one can then use together with a bisect, perhaps?
> 
> Not completely sure I followed, but moving up to that frame and printing
> visitor didn't work: "optimized out".

The code where this happens is this:

  for (int i = 0; i < staticidx; i++)
    visitor.visit (staticvec[i], GC_ROOT_STATICPRO, visitor.data);

So one way of knowing which staticpro is being handled here is to see
what is the value of 'i' and look at staticvec[i].  I'm guessing that
'i' is also "optimized out", though, so 2 possible ways forward:

  . disassemble visit_static_gc_roots, find in which register or where
    on the stack or in memory is 'i; or staticvec[i] stored, and go
    from there; or
  . add a printf to the above loop to show the value of 'i', and
    re-run the build, fingers crossed, hoping that the additional
    printf won't make the crash go away.

Once you know which staticpro is being processed here, we'd need to
examine its contents and try to figure out which parts cause the crash
in GC.

Thanks.