Subject: bug#28308: Build failure on FreeBSD/aarch64

From: [email-masked]
Date: Mon, 11 Sep 2017 02:07:56 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Gergely Czuczy <[email-masked]>
>> Date: Sat, 9 Sep 2017 07:01:20 +0200
>> Cc: [email-masked]
>> 
>> * thread #1, name = 'bootstrap-emacs', stop reason = signal SIGSEGV: 
>> invalid address (fault address: 0x41aef578)
>>    * frame #0: 0x0000000000228460 
>> bootstrap-emacs`xnrealloc(pa=0x0000000000000000, nitems=0, 
>> item_size=1101985151) at alloc.c:939
>>      frame #1: 0x0000000000228204 
>> bootstrap-emacs`xnrealloc(pa=0x000000000019ae38, nitems=42949672960, 
>> item_size=281474976703896) at alloc.c:939
>>      frame #2: 0x000000000022e208 
>> bootstrap-emacs`xpalloc(pa=0x0000000000000000, 
>> nitems=0x0000000041aef57f, nitems_incr_min=1683000, 
>> nitems_max=42949672960, item_size=281474976703896) at alloc.c:0
>>      frame #3: 0x0000000000168214 
>> bootstrap-emacs`delete_tty(terminal=0xbc7603df25a071f3) at term.c:4463
>>      frame #4: 0x0000000000040190 bootstrap-emacs`__start + 376
>>      frame #5: 0x0000000040390018 ld-elf.so.1`.rtld_start at rtld_start.S:41
>> (lldb)
>
> I don't understand how come xpalloc got called in this context.
> delete_tty on line 4463 of term,c calls delete_terminal, which only
> calls xfree.  It doesn't allocate any memory (of course), let alone
> with semi-bogus arguments as shown in this backtrace.

Frame #2 "at alloc.c:0" seems a bit fishy too.  Stack corruption?  Or is
it possible optimizations are interfering with the debug info?  Gergely,
could you try rebuiding with -O0 in addition to -g?