On Sun, Feb 18, 2018 at 11:32 AM, Eli Zaretskii wrote: > A thread that runs Lisp can continue running Lisp for a long time, and > will generate a lot of garbage. If GC is prevented, we will risk > running out of memory. > > IOW, leaving GC for the main thread only makes sense if we can be sure > the main thread will run shortly. But that cannot be guaranteed with > the current thread model, where a thread must exit or yield before > another thread can run. I was actually imagining that when a thread needed a GC it would request that the GC be done on the main thread (blocking while it waits). I have no idea how difficult that would be to implement. > If threads get only 512KB of stack, it's a small wonder that they > crash in GC. IME, you need at least 3MB to endure a full GC in Emacs. I upped the required stack size to 5MB and it fixed the crash for me. I don't know what the right size should bed, I could go w/ the 3MB you call out here, but I went a little higher to be safe. See attached patch. I'm assuming that pthread_attr_setstacksize is available everywhere pthread is. I don't know if that's an ok assumption or not. > What do you mean by "one thread at a time"? How was your program > changed for this run? I just meant that I C-x C-e on (company-dabbrev-thread "e" (lambda (words) (message "%S" words))), waited, did it again, etc, until crash. Aaron