From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 5b5f441: read_key_sequence: correct the handling of raw_keybuf in recursive calls Date: Thu, 23 Nov 2017 13:46:44 -0500 Message-ID: References: <20171120181210.7946F20416@vcs0.savannah.gnu.org> <20171120195918.GB3917@ACM> <20171120203004.GC3917@ACM> <20171122192522.GA4288@ACM> <20171122210426.GB4288@ACM> <20171123181017.GA5167@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511462714 1858 195.159.176.226 (23 Nov 2017 18:45:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 23 Nov 2017 18:45:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 23 19:45:07 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 1eHwUi-0008GG-6N for ged-emacs-devel@m.gmane.org; Thu, 23 Nov 2017 19:45:04 +0100 Original-Received: from localhost ([::1]:45651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHwUp-0003yp-Dx for ged-emacs-devel@m.gmane.org; Thu, 23 Nov 2017 13:45:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHwUi-0003yO-Uk for emacs-devel@gnu.org; Thu, 23 Nov 2017 13:45:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eHwUd-0004hD-0y for emacs-devel@gnu.org; Thu, 23 Nov 2017 13:45:02 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:33835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eHwUc-0004gd-Sk for emacs-devel@gnu.org; Thu, 23 Nov 2017 13:44:58 -0500 Original-Received: from lechazo.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id vANIiva5012885; Thu, 23 Nov 2017 13:44:57 -0500 Original-Received: by lechazo.home (Postfix, from userid 20848) id 692EC602DF; Thu, 23 Nov 2017 13:46:44 -0500 (EST) In-Reply-To: <20171123181017.GA5167@ACM> (Alan Mackenzie's message of "Thu, 23 Nov 2017 18:10:17 +0000") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6165=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6165> : inlines <6185> : streams <1771125> : uri <2538908> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:220408 Archived-At: >> Hmm... that might work, but I still can't imagine what comment I could >> write next to the code to explain/prove that it's safe. > It's as safe as the original, since the only buffer space used is the > original raw_keybuf, indexed by raw_keybuf_count. The only change is to > initialise raw_keybuf_count in different places, to allow the recursive > call to read_key_sequence not to overwrite the current buffer contents. I had misunderstood. Yes, that does look safe. No idea if it's correct enough in practice, but it looks much better than what we have. Thanks. >> Yet, with the new concurrency feature, the unwind might reset the >> global var to a pointer into a stack area on another thread, which may >> have gotten stale in the mean time. > If we've got two tasks simultaneously accessing that global buffer, > we're in deep trouble anyway. Obviously some sort of lock would need to > be applied to this and other global things. I think in this case eliminating this-single-command-raw-keys is a better solution, since we can then eliminate the global var. Stefan