Subject: Re: bug#32812: 27.0.50; macOS Mojave GNU Emacs crash after 5-10 minutes or so

From: "Zack Piper" <[email-masked]>
Date: Mon, 24 Sep 2018 12:39:22 +0100

(Final attempt at sending, TLS was being enforced for my outgoing 
emails, sorry Alan for the spam!)

Hi Alan,

On 24 Sep 2018, at 11:17, Alan Third wrote:

> On Sun, Sep 23, 2018 at 04:21:13PM +0100, Zack Piper wrote:
>> Hi!
>>
>> (Replacing my post in #31904 with this since they're separate 
>> issues(?))
>
> Sorry, I somehow missed that previous email.

No worries at all!

>> I've applied a slightly modified (i.e. updated) version of Alan's 
>> patch from
>> bug #31904
>> (attached) to fix an issue concerning the buffer and mode-line not 
>> being
>> rendered. The patch works great, everything is now rendered.
>>
>> Now I notice that after 5-10 minutes (or even before), Emacs crashes 
>> with
>> the below:
>>
>> ```
>> objc[82784]: Invalid or prematurely-freed autorelease pool 
>> 0x1030032e0.
>> ```
>>
>> This started occurring since upgrading to macOS Mojave, so possibly 
>> there's
>> a bug with Mojave or just some incompatibility, not really sure!
>
> It’s a bit strange looking, and autorelease pools are something of a
> mystery to me.
>
> I have a suspicion, though, that just creating a new autorelease pool
> may solve this. I’ve attached a patch. It’s for emacs-26, but 
> should
> apply OK to master, or without too much work anyway.

>
> It simply wraps the call to displayIfNeeded in a new pool:
>
> static void
> ns_flush_display (struct frame *f)
> /* Force the frame to redisplay.  If areas have previously been marked
>    dirty by setNeedsDisplayInRect (in ns_focus), then this will call
>    draw_rect: which will "expose" those areas.  */
> {
>   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>   [FRAME_NS_VIEW (f) displayIfNeeded];
>   [pool release];
> }

>
> Thanks for testing the patch and raising this issue. There’s not 
> been
> a lot of feedback so far and I think we’re going to have to commit 
> the
> patch soon given that Mojave is out today.

You're very welcome, and thanks for providing the additional patch!

(Later email):

> This patch doesn’t help, I finally reproduced the crash with it in
> place.

Oh, damn.

I truly wish I could help somewhat, if you need anything additional from 
me let me know.

I've never really meddled Objective C before, so I'd likely not be able 
to help much.

Obviously I'm more than happy to test any patches you throw at me! :-)

I did look at the autorelease pool thing and tried to see where it would 
fit in, to no avail.

Let me know if you need anything.

> -- 
> Alan Third

Thanks,
Zack