From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#10535: 23.3; starttls-negotiate-gnutls erases random buffer Date: Tue, 17 Jan 2012 18:11:15 -0500 Message-ID: <5sr4yxq60c.fsf@fencepost.gnu.org> References: <20245.27412.138376.596455@scylla.home.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1326841928 13723 80.91.229.12 (17 Jan 2012 23:12:08 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 17 Jan 2012 23:12:08 +0000 (UTC) Cc: 10535@debbugs.gnu.org To: walter@pelissero.de Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 18 00:12:04 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RnICC-0002LV-A7 for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jan 2012 00:12:04 +0100 Original-Received: from localhost ([::1]:41476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnICB-000600-O9 for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Jan 2012 18:12:03 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnIC9-0005zk-1f for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2012 18:12:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RnIC7-0006PY-T8 for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2012 18:12:01 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnIC7-0006PU-R2 for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2012 18:11:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RnID7-0006xi-T9 for bug-gnu-emacs@gnu.org; Tue, 17 Jan 2012 18:13:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <20245.27412.138376.596455@scylla.home.lan> Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jan 2012 23:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10535 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10535-submit@debbugs.gnu.org id=B10535.132684194526717 (code B ref 10535); Tue, 17 Jan 2012 23:13:01 +0000 Original-Received: (at 10535) by debbugs.gnu.org; 17 Jan 2012 23:12:25 +0000 Original-Received: from localhost ([127.0.0.1]:33956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RnICX-0006wr-Fg for submit@debbugs.gnu.org; Tue, 17 Jan 2012 18:12:25 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:38450) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RnICR-0006wg-1R for 10535@debbugs.gnu.org; Tue, 17 Jan 2012 18:12:23 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RnIBP-0003Kq-HS; Tue, 17 Jan 2012 18:11:15 -0500 X-Spook: MD5 genetic codes red noise Saudi Arabia Venezuela Lon X-Ran: yE$04fRA#^i*\DPMFit7{x`G8W=K(0p$P`gNs3a9`{Qu82cA$[wORB=/LzSWwt}q8mW|~> X-Hue: magenta X-Attribution: GM User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55831 Archived-At: Walter C. Pelissero wrote: > starttls-negotiate-gnutls obliterates the contents of the second > buffer in the buffers list. > > For instance a form like this may expose the bug: > > (jabber-starttls-connect '(:fsm jabber-connection :state :connecting :state-data (:send-function jabber-ssl-send :username "me" :server "jabme.de" :password "secret" :registerp nil :connection-type starttls :encrypted nil :network-server nil :port nil) :sleep 3 :deferred nil) "jabber.host" nil nil) > > I've noticed that the local variable `buffer' in > starttls-negotiate-gnutls may contain a killed buffer, which I guessed > it might be the source of the problem. I didn't try to reproduce this (not having jabber installed), but I don't see how that could be the source of any such issue. Eg: (with-temp-buffer (setq foo (current-buffer))) (with-current-buffer foo (insert "hi")) does not insert "hi" in a random buffer, but stops with "(error "Selecting deleted buffer")" > the following patch seems to fix the problem at least in starttls. > The patch, despite it's length (diff -w can be useful) > , just checks that the buffer is still alive. > ! (if (and buffer (buffer-live-p buffer)) > ! (with-current-buffer buffer As shown above, a buffer that is not live should already cause an error, so I don't see how adding a buffer-live-p test can help. > In fact the following code erases the content of any writable buffer > happening to be second in the buffers list: > > (let ((buffer (generate-new-buffer "foobar"))) > (with-current-buffer buffer (kill-buffer buffer) (erase-buffer))) > > Although I don't know if the behaviour above is to be expected, It is expected (and is not related to anything starttls-negotiate-gnutls is doing AFAICS). The Elisp manual section on "Killing Buffers" cautions about such usage.