From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#34318: 26.1.90; Strange behavior of two line message with running shell Date: Tue, 12 Feb 2019 16:34:00 -0500 Message-ID: References: <5C5889D7.5020102@gmx.at> <874l9j9oyq.fsf@igel.home> <5C594AF8.2040107@gmx.at> <5C5963BE.6080800@gmx.at> <5C5D52AC.4060501@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="207045"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 34318@debbugs.gnu.org, Andreas Schwab To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 12 22:45:56 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtfsI-000rgq-VG for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Feb 2019 22:45:55 +0100 Original-Received: from localhost ([127.0.0.1]:46521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtfsH-000452-Sy for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Feb 2019 16:45:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtfoS-0000pv-SK for bug-gnu-emacs@gnu.org; Tue, 12 Feb 2019 16:41:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtfhn-00006A-DA for bug-gnu-emacs@gnu.org; Tue, 12 Feb 2019 16:35:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46006) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtfhm-0008Vz-6O for bug-gnu-emacs@gnu.org; Tue, 12 Feb 2019 16:35:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gtfhl-0000vD-VT for bug-gnu-emacs@gnu.org; Tue, 12 Feb 2019 16:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Feb 2019 21:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34318 X-GNU-PR-Package: emacs Original-Received: via spool by 34318-submit@debbugs.gnu.org id=B34318.15500072463472 (code B ref 34318); Tue, 12 Feb 2019 21:35:01 +0000 Original-Received: (at 34318) by debbugs.gnu.org; 12 Feb 2019 21:34:06 +0000 Original-Received: from localhost ([127.0.0.1]:45287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gtfgr-0000tw-Iv for submit@debbugs.gnu.org; Tue, 12 Feb 2019 16:34:05 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:38819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gtfgo-0000tn-Ou for 34318@debbugs.gnu.org; Tue, 12 Feb 2019 16:34:04 -0500 Original-Received: from milanesa.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id x1CLY0ku011992; Tue, 12 Feb 2019 16:34:00 -0500 Original-Received: by milanesa.home (Postfix, from userid 20848) id 2FFF866140; Tue, 12 Feb 2019 16:34:00 -0500 (EST) In-Reply-To: <5C5D52AC.4060501@gmx.at> (martin rudalics's message of "Fri, 08 Feb 2019 10:58:04 +0100") 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, RV6481=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6481> : inlines <7017> : streams <1812856> : uri <2795312> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:155386 Archived-At: > The problem is with > > 2018-06-03 Stefan Monnier > > Fix bug#30846, along with misc cleanups found along the way > > and in particular > > Don't call swap_in_symval_forwarding since the currently swapped > binding is never one we've modified. Indeed, good spotting. I installed the patch below which mostly reverts this part of the commit. > So please, pretty please review that entire patch again - maybe it > contains additional sorts of problems. This is a rather tricky part of the code, indeed. I reviewed it thoroughly before installing it and yet here we are. I re-reviewed it now and couldn't spot any further mistakes, but you know what this means. Stefan diff --git a/src/data.c b/src/data.c index 571114802a..ed6dedbe24 100644 --- a/src/data.c +++ b/src/data.c @@ -1954,6 +1954,16 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) (current_buffer, Fcons (Fcons (variable, XCDR (blv->defcell)), BVAR (current_buffer, local_var_alist))); + + /* If the symbol forwards into a C variable, then load the binding + for this buffer now, to preserve the invariant that forwarded + variables must always hold the value corresponding to the + current buffer (they are swapped eagerly). + Otherwise, if C code modifies the variable before we load the + binding in, then that new value would clobber the default binding + the next time we unload it. See bug#34318. */ + if (blv->fwd) + swap_in_symval_forwarding (sym, blv); } return variable; diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 0069ee84fe..f3b4262de4 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el @@ -508,4 +508,22 @@ binding-test-some-local (bound-and-true-p data-tests-foo2) (bound-and-true-p data-tests-foo3))))))) +(ert-deftest data-tests-make-local-forwarded-var () ;bug#34318 + ;; Boy, this bug is tricky to trigger. You need to: + ;; - call make-local-variable on a forwarded var (i.e. one that + ;; has a corresponding C var linked via DEFVAR_(LISP|INT|BOOL)) + ;; - cause the C code to modify this variable from the C side of the + ;; forwarding, but this needs to happen before the var is accessed + ;; from the Lisp side and before we switch to another buffer. + ;; The trigger in bug#34318 doesn't exist any more because the C code has + ;; changes. Instead I found the trigger below. + (with-temp-buffer + (setq last-coding-system-used 'bug34318) + (make-local-variable 'last-coding-system-used) + ;; This should set last-coding-system-used to `no-conversion'. + (decode-coding-string "hello" nil) + (should (equal (list last-coding-system-used + (default-value 'last-coding-system-used)) + '(no-conversion bug34318))))) + ;;; data-tests.el ends here