* Re-entering the event loop
@ 2016-06-18 11:38 Alan Third
0 siblings, 0 replies; only message in thread
From: Alan Third @ 2016-06-18 11:38 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]
The NS port has an event loop that contains this code:
if (++apploopnr != 1)
{
emacs_abort ();
}
So if the loop is entered again it crashes Emacs instantly and gives
a stack trace. This shows up in a couple of bugs.
Bug#11049, for example, is where it receives a SIGHUP and should quit
cleanly and write out backups of open buffers, etc. but actually just
crashes because it re-enters the event loop.
What happens here is that the SIGHUP is received as an event, which
then calls a function that unblocks *all* input. Then Emacs tries to
clean up before quitting but that results with it handling input
events again, therefore re-entering the event loop and aborting.
I've sent a patch to this bug that simply re-blocks input, but the
alternative is to remove this check and let Emacs re-enter the event
loop. As far as I can tell this works fine for this particular case
(SIGHUP), but I don't know if it will break something else.
Is there any way, other than sending signal to kill it, that would
result in Emacs re-entering the event loop?
Thanks!
--
Alan Third
[-- Attachment #2: Remove event loop abort --]
[-- Type: text/plain, Size: 1766 bytes --]
diff --git a/src/nsterm.m b/src/nsterm.m
index f2b0d90..10e22fd 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -288,7 +288,6 @@ - (NSColor *)colorUsingDefaultColorSpace
static struct timespec select_timeout = { 0, 0 };
static int selfds[2] = { -1, -1 };
static pthread_mutex_t select_mutex;
-static int apploopnr = 0;
static NSAutoreleasePool *outerpool;
static struct input_event *emacs_event = NULL;
static struct input_event *q_event_ptr = NULL;
@@ -4054,15 +4053,6 @@ in certain situations (rapid incoming events).
}
#endif /* NS_IMPL_COCOA */
-static void
-unwind_apploopnr (Lisp_Object not_used)
-{
- --apploopnr;
- n_emacs_events_pending = 0;
- ns_finish_events ();
- q_event_ptr = NULL;
-}
-
static int
ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
/* --------------------------------------------------------------------------
@@ -4126,13 +4116,8 @@ in certain situations (rapid incoming events).
send_appdefined = YES;
ns_send_appdefined (-1);
- if (++apploopnr != 1)
- {
- emacs_abort ();
- }
- record_unwind_protect (unwind_apploopnr, Qt);
[NSApp run];
- unbind_to (specpdl_count, Qnil); /* calls unwind_apploopnr */
+ unbind_to (specpdl_count, Qnil);
}
nevents = n_emacs_events_pending;
@@ -4235,16 +4220,10 @@ in certain situations (rapid incoming events).
block_input ();
ns_init_events (&event);
- if (++apploopnr != 1)
- {
- emacs_abort ();
- }
-
{
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
- record_unwind_protect (unwind_apploopnr, Qt);
[NSApp run];
- unbind_to (specpdl_count, Qnil); /* calls unwind_apploopnr */
+ unbind_to (specpdl_count, Qnil);
}
ns_finish_events ();
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-18 11:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-18 11:38 Re-entering the event loop Alan Third
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.