From: Kai Ma <justksqsf@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Po Lu <luangruo@yahoo.com>, emacs-devel@gnu.org
Subject: Re: [PATCH] On the nasty "ghost key" problem on NS
Date: Sat, 5 Nov 2022 23:26:35 +0800 [thread overview]
Message-ID: <73CA0A70-2D98-4BC9-B474-2D69373A245A@gmail.com> (raw)
In-Reply-To: <jwva655sc35.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2075 bytes --]
> On Nov 5, 2022, at 22:40, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>>> - if (WINDOWP (echo_area_window) && ! NILP (call0 (intern ("ns-in-echo-area"))))
>>> + was_waiting_for_input = waiting_for_input;
>>> + waiting_for_input = false;
>>> + specbind (Qinhibit_quit, Qt);
>>> + if (WINDOWP (echo_area_window) && ! NILP (safe_call (true, 0, Qns_in_echo_area)))
>>>
>>> I'm glad we found a way to make the code work, apparently, but
>>> Here we need a comment explaining why we do this gymnastic of
>>> `safe_call` + `inhibit_quit` + `waiting_for_input`.
>>
>> That is done all over the place in the NS code.
>
> Then why does it need to be hand-coded here? If it's done all over the
> place, it should have its own `super_extra_safe_call` function or
> something, no?
>
>> I don't really know why, you will have to ask its original authors for
>> that, but suffice it to say calling Lisp from
>> firstRectForCharacterRange (and also the menu bar update callbacks)
>> will otherwise crash upon Fsignal being called.
>
> Yet I don't see anything in `ns-in-echo-area` which would call `signal`.
> I don't mean to say that we should not protect ourselves from the case
> where `ns-in-echo-area` calls `signal`, but that the above explanation
> doesn't seem to explain the problem we're currently facing.
> [ And `safe_call` should be sufficient to protect ourselves from
> `signal`. ]
I’m not super familiar with the signal mechanism, but here are some findings. (Assume that `waiting_for_input` is correctly maintained.) On certain occasions (which still remain unclear to me), the `Vthrow_on_input` path in `process_quit_flag` is taken. The curious thing is that `safe_call` does not seem to catch that, and thus the control flow directly moves to somewhere above the Lisp call in `firstRectForCharacterRange`. Is it intentional that `safe_call` does not catch throw_on_input?
(Also a correction: I guessed it could be related to threading at first. No, it’s not. It’s always the main thread.)
[-- Attachment #2: Type: text/html, Size: 2725 bytes --]
next prev parent reply other threads:[~2022-11-05 15:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 18:07 [PATCH] On the nasty "ghost key" problem on NS Kai Ma
2022-11-04 0:32 ` Po Lu
2022-11-04 6:28 ` Kai Ma
2022-11-04 7:16 ` Po Lu
2022-11-04 8:53 ` Kai Ma
2022-11-04 9:29 ` Po Lu
2022-11-04 11:04 ` Kai Ma
2022-11-04 11:27 ` Po Lu
2022-11-04 12:09 ` Kai Ma
2022-11-04 12:17 ` Po Lu
2022-11-04 15:09 ` Stefan Monnier
2022-11-05 0:43 ` Po Lu
2022-11-05 14:40 ` Stefan Monnier
2022-11-05 15:26 ` Kai Ma [this message]
2022-11-05 15:47 ` Stefan Monnier
2022-11-06 0:25 ` Po Lu
2022-11-10 11:59 ` Kai Ma
2022-11-10 12:25 ` Po Lu
2022-11-12 17:49 ` Stefan Monnier
2022-11-04 11:40 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73CA0A70-2D98-4BC9-B474-2D69373A245A@gmail.com \
--to=justksqsf@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.