Subject: bug#16039: repeated emacs crashes (in GC?)

From: Eli Zaretskii <[email-masked]>
Date: Wed, 04 Dec 2013 05:49:46 +0200

> Date: Wed, 04 Dec 2013 09:43:00 +0900
> From: YAMAMOTO Mitsuharu <[email-masked]>
> Cc: emacs user <[email-masked]>,
> 	[email-masked]
> 
> >>>>> On Tue, 03 Dec 2013 18:01:21 +0200, Eli Zaretskii <[email-masked]> said:
> 
> >> I wrote YAMAMOTO Mitsuharu, the Emacs for mac developer, and his
> >> response is
> >> 
> >> > The backtrace shows that the stack is used up because some deeply
> >> > nested Lisp data structure is recursively traversed in garbage >
> >> > collection (or possibly an unknown bug in the GC code).  In
> >> > normal OSX applications, the stack depth for the main thread is
> >> > set to 8MiB by default, and Emacs slightly enlarges it to
> >> > 8720000B (on 64-bit binary) by some formula in src/emacs.c:
> 
> > What is the evidence that the stack is used up?
> 
> The backtrace shows it crashed by accessing the address exceeding the
> stack boundary:
> 
>   * thread #1: tid = 0x484e3, 0x00000001000f61d1 Emacs`mark_object + 1073,
>   queue = 'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=2,
>   address=0x7fff5f3aeff8)
> 
> Below is extracted from the memory map (% vmmap -interleaved PID):
> 
>   STACK GUARD            00007fff5bc00000-00007fff5f3af000 [ 55.7M] ---/rwx SM=NUL  stack guard for thread 0
>   Stack                  00007fff5f3af000-00007fff5f400000 [  324K] rw-/rwx SM=NUL  thread 0
>   Stack                  00007fff5f400000-00007fff5fbff000 [ 8188K] rw-/rwx SM=PRV  thread 0
> 
> > Having 136 thousand frames during GC is not unheard of.
> 
> (/ 8720000.0 (* 136 1000))
> 64.11764705882354
> 
> If each frame consumes more than 64 bytes, then it will use up
> 8720000B stack space.

Thanks.  I'd suggest to enlarge the stack (e.g., double it), and try
again.  If the stack is still overflowed, then there's probably some
GC-related problem.