Subject: bug#25265: make-thread crashes in OS X 10.6

From: Eli Zaretskii <[email-masked]>
Date: Tue, 27 Dec 2016 09:30:28 +0200

> Date: Mon, 26 Dec 2016 20:56:32 +0000
> From: Alan Third <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> > Can you try and figure out why it hangs?
> 
> I’m not having any luck with this. My entirely uneducated guess is
> that the main thread can’t access the contents of current_thread. It
> crashes on this line:
> 
>     while (specpdl_ptr != specpdl + count)
> 
> with EXC_BAD_ACCESS. Only three things are being accessed: count,
> which is a function argument, and specpdl and specpdl_ptr are
> #defines to variables within current_thread.

The loop above is in unbind_to, right?

> I can’t access anything within current_thread using lldb, but I can
> see current_thread itself. I don’t know if that signifies anything.

I have bad experience with using lldb (not on OS X, though), so I
don't trust it.  Can you use GDB instead?  Failing that, is it
possible to just fprintf these values to stderr?

It is strange that this is where it hangs, since these are
thread-specific variables.  Maybe the problem is that apploopnr is a
static variable, and some other thread stomps on it?

> I’ll put the complete backtrace at the bottom of this email.

I don't see any backtraces attached.

> >     [NSApp run];
> > 
> > Can this part and its surrounding code be made thread-safe?
> 
> I think this particular method call has to be done *only* from the
> main thread. I imagine that could be a problem.

It could be a problem, yes.  But what does this do, exactly, and why
does it need to be called as part of ns_select?

Also, why does ns_select sometimes call pselect instead -- is that for
non-interactive or non-GUI sessions or something?

Thanks.