From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 1392ec7 2/3: A quicker check for quit Date: Thu, 26 Jan 2017 09:45:09 -0800 Organization: UCLA Computer Science Department Message-ID: References: <20170126052541.29089.5382@vcs.savannah.gnu.org> <20170126052542.828422201BC@vcs.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1485452809 15847 195.159.176.226 (26 Jan 2017 17:46:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2017 17:46:49 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 To: Stefan Monnier , Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 26 18:46:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWo7r-0001vO-7Q for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2017 18:46:23 +0100 Original-Received: from localhost ([::1]:40265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWo7t-0004Qv-3n for ged-emacs-devel@m.gmane.org; Thu, 26 Jan 2017 12:46:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWo6m-0003ua-Ee for emacs-devel@gnu.org; Thu, 26 Jan 2017 12:45:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWo6i-00062d-HK for emacs-devel@gnu.org; Thu, 26 Jan 2017 12:45:16 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45968) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWo6i-00062T-BD for emacs-devel@gnu.org; Thu, 26 Jan 2017 12:45:12 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4D8231600C8; Thu, 26 Jan 2017 09:45:10 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id h-PswS-xa1js; Thu, 26 Jan 2017 09:45:09 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 88C781600CA; Thu, 26 Jan 2017 09:45:09 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id of2QrtjosHgf; Thu, 26 Jan 2017 09:45:09 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 714441600C8; Thu, 26 Jan 2017 09:45:09 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211621 Archived-At: 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.