From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: riccardo.murri@gmail.com (Riccardo Murri) Newsgroups: gmane.emacs.bugs Subject: url-retrieve-synchronously randomly fails on https URLs (patch included) Date: Sat, 27 Oct 2007 12:47:16 +0200 (CEST) Message-ID: <20071027104716.E9BA773545@tanja.localdomain> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1193484087 32516 80.91.229.12 (27 Oct 2007 11:21:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Oct 2007 11:21:27 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 27 13:21:29 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IljjM-0000vv-Vh for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2007 13:21:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IljjE-0007TT-3I for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Oct 2007 07:21:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IljCN-000830-0X for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2007 06:47:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IljCL-000805-HJ for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2007 06:47:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IljCL-000800-9h for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2007 06:47:21 -0400 Original-Received: from smtpout4.mclink.it ([195.110.128.205]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IljCK-0000gW-NT for bug-gnu-emacs@gnu.org; Sat, 27 Oct 2007 06:47:21 -0400 Original-Received: from mailhubirp.mclink.it (mailhubirp.mclink.it [195.110.128.214]) by smtpout4.mclink.it (8.13.6/8.13.6) with ESMTP id l9RAlHH8054968 for ; Sat, 27 Oct 2007 12:47:17 +0200 (CEST) (envelope-from riccardo.murri@gmail.com) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq4HAMazIkfVy5G2/2dsb2JhbACBWo5s Original-Received: from adsl203-145-182.mclink.it (HELO tanja.localdomain) ([213.203.145.182]) by mail.mclink.it with ESMTP; 27 Oct 2007 12:47:17 +0200 Original-Received: by tanja.localdomain (Postfix, from userid 1000) id E9BA773545; Sat, 27 Oct 2007 12:47:16 +0200 (CEST) X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (2) X-Mailman-Approved-At: Sat, 27 Oct 2007 07:20:57 -0400 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16853 Archived-At: To trigger the error just try a few times:: (url-retrieve-synchronously "https://www.google.com/") Error backtrace:: Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) url-http-wait-for-headers-change-function(1 199 198) url-http-generic-filter(# "EF344D7E1950942DBA877D79DDD8100A21A2592D03A210A4109\n Key-Arg : None\n Start Time: 1193480981\n Timeout : 300 (sec)\n Verify return code: 20 (unable to get local issuer certificate)\n---\n") accept-process-output(#) byte-code("=8c2=8c3 !)=87" [inhibit-quit proc nil accept-process-output] 2) url-retrieve-synchronously("https://www.google.com/") (kill-buffer (url-retrieve-synchronously "https://www.google.com/")) eval((kill-buffer (url-retrieve-synchronously "https://www.google.com/"))) eval-last-sexp-1(t) eval-last-sexp(t) eval-print-last-sexp() call-interactively(eval-print-last-sexp) Sample contents of the URL retrieve buffer after a failed request:: EF344D7E1950942DBA877D79DDD8100A21A2592D03A210A4109 Key-Arg : None Start Time: 1193480981 Timeout : 300 (sec) Verify return code: 20 (unable to get local issuer certificate) --- HTTP/1.1 302 Found Location: http://www.google.com Date: Sat, 27 Oct 2007 10:29:41 GMT Content-Type: text/html; charset=UTF-8 Server: GFE/1.3 Content-Length: 218 302 Moved

302 Moved

The document has moved here. read:errno=0 I traced down the bug to `open-tls-stream', which returns immediately after having seen the regexp `tls-success' in the buffer. However, both `openssl s_client' and `gnutls' print more information after that line, thus `open-tls-stream' may occasionally return the buffer to the caller when point is still amidst openssl/gnutls output. A solution is to have `open-tls-stream' wait a little more to accept output; after applying the patch below I cannot trigger the error anymore. --- src/emacs22/lisp/net/tls.el 2007-08-05 21:06:12.000000000 +0200 +++ emacs/lisp/tls.el 2007-10-27 12:23:47.000000000 +0200 @@ -154,9 +154,14 @@ (sit-for 1))) (message "Opening TLS connection with `%s'...%s" cmd (if done "done" "failed")) - (if done - (setq done process) - (delete-process process)))) + (if (not done) + (delete-process process) + ;; both `openssl s_client' and `gnutls' print some more info + ;; after the line matched by regexp `tls-success'; wait here + ;; a bit more, so we can be sure that point is at the end of + ;; it all, before handing the buffer back to caller + (accept-process-output process 1) + (setq done process)))) (message "Opening TLS connection to `%s'...%s" host (if done "done" "failed")) (when use-temp-buffer Riccardo In GNU Emacs 22.1.1 (powerpc-unknown-linux-gnu, GTK+ Version 2.10.13) of 2007-08-22 on voltaire, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.70101000 configured using `configure '--build=powerpc-linux-gnu' '--host=powerpc-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=powerpc-linux-gnu' 'host_alias=powerpc-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: it_IT.UTF-8 locale-coding-system: utf-8 default-enable-multibyte-characters: t Major mode: Text Minor modes in effect: tooltip-mode: t tool-bar-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t unify-8859-on-encoding-mode: t utf-translate-cjk-mode: t auto-compression-mode: t line-number-mode: t Recent input: C-SPC C-e w C-x 4 b C-y C-j C-x C-e C-x C-e C-x C-e C-x C-e C-x C-e C-x C-e C-x C-e C-x 0 Recent messages: t Contacting host: www.google.com:443 Reading [text/html; charset=UTF-8]... 226 bytes of 218 bytes (104%) Reading... done. Reading [text/html]... 227 bytes of 218 bytes (104%) www.google.it tried to set a cookie for domain .google.it - rejected. t Loading emacsbug... Loading regexp-opt...done Loading emacsbug...done