|
From: | Paul Eggert |
Subject: | Re: [Emacs-diffs] master 1392ec7 2/3: A quicker check for quit |
Date: | Thu, 26 Jan 2017 09:45:09 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
On 01/26/2017 05:40 AM, Stefan Monnier wrote:
IIRC we have moved some QUIT checks*into* loops in the past in order to be able to interrupt inf-loops, such as when you do (memq 4 '#1=(1 . #1#)).
I was under the impression that if immediate_quit is true, then a tight loop in C doesn't need to call maybe_quit (the new name for QUIT), as C-g will error out immediately. There is longstanding code in the interpreter that assumes this, for example in the implementation of nth.
Unfortunately my impression is incorrect. If you byte-compile this: (defun foo () (nth most-positive-fixnum '#1=(1 . #1#)))and load the resulting .elc file and then execute (foo) on a 64-bit Emacs displaying X, then C-g does not interrupt Emacs and Emacs hangs while counting up to 2**61. (C-g works as expected with emacs -nw.) I will look into fixing this longstanding bug, as well as fixing similar bugs that I recently introduced.
This leads me to wonder: what's the point of immediate_quit? If immediate_quit doesn't always cause C-g to immediately quit, why are we bothering with an immediate_quit variable? Or if immediate_quit makes sense, then should we arrange for a C-g under X to behave more like C-g on a terminal, and do a longjmp? (Shudder.)
Of course, for circular lists a better solution is to use the hare&tortoise, e.g. with FOR_EACH_TAIL.
Yes, that's something that could be done in these cases too. I'd like to get C-g fixed first, though.
[Prev in Thread] | Current Thread | [Next in Thread] |