From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Vivek Dasmohapatra Newsgroups: gmane.emacs.bugs Subject: url libraries can reult in destruction of wrong buffer after 401 Date: Tue, 28 Sep 2004 16:13:13 +0100 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1096384436 15632 80.91.229.6 (28 Sep 2004 15:13:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 28 Sep 2004 15:13:56 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 28 17:13:45 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CCJfl-0005Jf-00 for ; Tue, 28 Sep 2004 17:13:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CCJm2-0000ae-VR for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 Sep 2004 11:20:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CCJm0-0000aY-FI for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 11:20:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CCJm0-0000aM-2K for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 11:20:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CCJm0-0000aJ-0C for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 11:20:12 -0400 Original-Received: from [212.44.21.72] (helo=watergate.zeus.co.uk) by monty-python.gnu.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.34) id 1CCJfN-0005wS-Oh for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 11:13:21 -0400 Original-Received: from gyros-1.zeus.com ([212.44.21.82] helo=cam-gw.zeus.com) by watergate.zeus.co.uk with esmtp (Exim 4.33) id 1CCJf2-0005Kq-DA for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 16:13:00 +0100 Original-Received: from arachne.cam.zeus.com ([10.100.1.102] ident=mail) by cam-gw.zeus.com with esmtp (Exim 3.35 #1 (Debian)) id 1CCJfG-0000T2-00 for ; Tue, 28 Sep 2004 16:13:14 +0100 Original-Received: from vivek by arachne.cam.zeus.com with local (Exim 4.33) id 1CCJfF-0001xO-I8 for bug-gnu-emacs@gnu.org; Tue, 28 Sep 2004 16:13:13 +0100 Original-To: bug-gnu-emacs@gnu.org X-Scanner: exiscan *1CCJfG-0000T2-00*YBhr5NphPPU* (Zeus Technology Ltd) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list 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 Xref: main.gmane.org gmane.emacs.bugs:9104 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:9104 This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English, because the Emacs maintainers do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. In GNU Emacs 21.3.1 (i386-pc-linux-gnu, X toolkit) of 2004-08-26 on nessus, modified by Debian configured using `configure '--build=i386-linux' '--host=i386-linux' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--with-x=yes' '--with-x-toolkit=athena' '--without-toolkit-scroll-bars' 'CFLAGS=-DDEBIAN -g -O2' 'build_alias=i386-linux' 'host_alias=i386-linux'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: ja_JP value of $LC_CTYPE: ja_JP value of $LC_MESSAGES: en_GB value of $LC_MONETARY: en_GB value of $LC_NUMERIC: en_GB value of $LC_TIME: en_GB value of $LANG: ja_JP locale-coding-system: japanese-iso-8bit default-enable-multibyte-characters: t Please describe exactly what actions triggered the bug and the precise symptoms of the bug: Fetching a url with url-retrieve can reult in an anrbitrary buffer being killed if a 401 (or possibly a 407) result is encountered: url-http-parse-headers calls url-http-handle-authentication, which can call url-retrieve. This results in the current buffer being killed, and a new http buffer being generated. However, when the old http buffer is killed, emacs picks the top buffer from the list as the new current buffer, so by the time we get to the end of url-http-parse-headers, _that_ buffer is marked as dead even though it is not necessarily a url buffer, so next time the url libraries reap their dead buffers, an innocent bystander buffer is killed instead (and an obsolete http buffer may be left lying around too). A possible fix (which I am currently using) is to call set-buffer on the return value of url-http-parse-headers: (case url-http-response-status (401 ;; The request requires user authentication. The response ;; MUST include a WWW-Authenticate header field containing a ;; challenge applicable to the requested resource. The ;; client MAY repeat the request with a suitable ;; Authorization header field. (url-mark-buffer-as-dead (current-buffer)) (set-buffer (url-http-handle-authentication nil))) etc .... which makes sure that it is the right http buffer that is current when we come to mark the http buffers as dead.