GNU bug report logs - #15227
Possible bug in (web server)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Shane Celis <shane.celis@HIDDEN>; dated Sat, 31 Aug 2013 07:12:02 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 15227 <at> debbugs.gnu.org:


Received: (at 15227) by debbugs.gnu.org; 13 Sep 2013 13:36:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 13 09:36:19 2013
Received: from localhost ([127.0.0.1]:33069 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VKTXm-0007pl-R9
	for submit <at> debbugs.gnu.org; Fri, 13 Sep 2013 09:36:19 -0400
Received: from mail-wg0-f41.google.com ([74.125.82.41]:40356)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <ianprice90@HIDDEN>) id 1VKTXj-0007pX-Uk
 for 15227 <at> debbugs.gnu.org; Fri, 13 Sep 2013 09:36:16 -0400
Received: by mail-wg0-f41.google.com with SMTP id l18so776492wgh.4
 for <15227 <at> debbugs.gnu.org>; Fri, 13 Sep 2013 06:36:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=googlemail.com; s=20120113;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version:content-type;
 bh=pPPY+NANo4XlMuMigUwzCOAuVqrx9YKLNIuM97M7wKw=;
 b=Qk6nwFiG4tRFXEMLuTVAqnz+T0ib9yWIhQsslVAcZ/qGGlWMFYCUdoVmyc7nUUYl5t
 PbO38fPPYtUhomwgmOgnUkWfO8x30gFpkRZhh2elGr5Ut0bfaw8fV+s+svfGh8YkGzSM
 0C+OlcZYWB3b7MqG/vpgG1PmxSFT8gc0OAaBwfaxfWDYT/MZ9Q/RKNZuWY+LvaBlsymk
 DqIwuiW2a5VQoZofNIGPfOf30zEak4godTZFMI0w8vVIEIwOirO7rGlPePz/+ZytwO2D
 XQuK2lKYbWDoRja6ESFBTg261usv5rQNBy3F9rJfv/NH+FqGyLW8PlZaJwiccB0mYeD7
 zNpA==
X-Received: by 10.180.76.171 with SMTP id l11mr2586977wiw.39.1379079370068;
 Fri, 13 Sep 2013 06:36:10 -0700 (PDT)
Received: from Kagami.home (host109-150-135-12.range109-150.btcentralplus.com.
 [109.150.135.12])
 by mx.google.com with ESMTPSA id d11sm3627882wic.4.1969.12.31.16.00.00
 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
 Fri, 13 Sep 2013 06:36:09 -0700 (PDT)
From: Ian Price <ianprice90@HIDDEN>
To: Shane Celis <shane.celis@HIDDEN>
Subject: Re: bug#15227: Possible bug in (web server)
References: <CB238240-1C7E-4703-B8DB-733764230E5F@HIDDEN>
Date: Fri, 13 Sep 2013 14:36:04 +0100
In-Reply-To: <CB238240-1C7E-4703-B8DB-733764230E5F@HIDDEN> (Shane Celis's
 message of "Sat, 31 Aug 2013 03:11:10 -0400")
Message-ID: <87vc24zvwb.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
X-Spam-Score: -0.4 (/)
X-Debbugs-Envelope-To: 15227
Cc: 15227 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.4 (/)

Shane Celis <shane.celis@HIDDEN> writes:

> ;; GNU/Linux bug
> ;; ------------
> ;; 
> ;; Info
> ;; ----
> ;;
> ;; $ uname -a
> ;; Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux
> ;;
> ;; $ guile --version
> ;; guile (GNU Guile) 2.0.9 [...]
> ;;
> ;; $ bash ./build-aux/config.guess
> ;; i686-pc-linux-gnu
> ;;
> ;; $ ./config.status --config
> ;;
> ;; Running
> ;; -------
> ;;
> ;; $ ./guile-web-server-osx-bug.scm server 
> ;; Web server replied 'Hello World! 0'.
> ;;
> ;; ---
> ;;
> ;; $ ./guile-web-server-osx-bug.scm client
> ;; Getting http://gnu.org... response #<<response> [...]
> ;;
> ;; Getting http://fsf.org... response #<<response> [...]
> ;;
> ;; Getting http://localhost:8080...SIGALRM called; timedout.
> ;;
> ;; If I try to connect to http://localhost:8080 through a web browser,
> ;; it works fine; so it seems like the (web client) is not working on
> ;; GNU/Linux and the (web server) is not working on Mac OS X.
> ;; 
If I run the client under strace I get

read(13, "HTTP/1.1 200 OK\r\nContent-Length: 15\r\nContent-Type: text/plain;charset=utf-8\r\n\r\nHello World! 22", 4096) = 94
read(13, 0xa1ec000, 4096)               = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

so even though we've read all the data that's needed, we're still making
another call to read and blocking.

One problem was that read-response-body was making a call to
get-bytevector-all, but even after changing it to

(define (read-response-body r)
  "Reads the response body from R, as a bytevector.  Returns
‘#f’ if there was no response body."
  (let ((body (and=> (response-body-port r #:decode? #f)
                     (lambda (p)
                       (cond ((response-content-length r) =>
                              (lambda (n)
                                (get-bytevector-n p n)))
                             (else (get-bytevector-all p)))))))
    ;; Reading a body of length 0 will result in get-bytevector-all
    ;; returning the EOF object.
    (if (eof-object? body)
        #vu8()
        body)))

I'm still seeing the same behaviour. (I did check and the
get-bytevector-n case is definitely being ran)

So, I'm guessing the problem lies in the C code for handling ports,
and/or for handling sockets.

No idea why it doesn't happen on web calls but only localhost.

Aside:
The above change to read-response-body has not been committed. I'm
undecided as to whether or not read-response-body should handle checking
the size of the content body. Currently it doesn't, but we have separate
code for doing that in (web client), so maybe not. But it might be an
idea to document that read-response-body may return less bytes than the
content length.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"




Information forwarded to bug-guile@HIDDEN:
bug#15227; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Aug 2013 07:11:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 31 03:11:37 2013
Received: from localhost ([127.0.0.1]:60748 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VFfLM-0004pf-1s
	for submit <at> debbugs.gnu.org; Sat, 31 Aug 2013 03:11:36 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37844)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfLJ-0004pQ-ER
 for submit <at> debbugs.gnu.org; Sat, 31 Aug 2013 03:11:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfL9-0002EI-6X
 for submit <at> debbugs.gnu.org; Sat, 31 Aug 2013 03:11:28 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:59225)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfL9-0002EE-2f
 for submit <at> debbugs.gnu.org; Sat, 31 Aug 2013 03:11:23 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39554)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfL4-0005cq-1R
 for bug-guile@HIDDEN; Sat, 31 Aug 2013 03:11:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfKz-0002CS-2T
 for bug-guile@HIDDEN; Sat, 31 Aug 2013 03:11:17 -0400
Received: from mail-qa0-x22a.google.com ([2607:f8b0:400d:c00::22a]:33139)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <shane.celis@HIDDEN>) id 1VFfKy-0002CF-SM
 for bug-guile@HIDDEN; Sat, 31 Aug 2013 03:11:12 -0400
Received: by mail-qa0-f42.google.com with SMTP id cm18so140566qab.8
 for <bug-guile@HIDDEN>; Sat, 31 Aug 2013 00:11:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:content-type:content-transfer-encoding:subject:message-id:date
 :to:mime-version;
 bh=6fZvwfETDwhURibRdk7OxPkoEUP3KFEQi+9FlP4XDDg=;
 b=WbDHCU1pNz+RgIr6xJk8Cns2K3aOQLirLvVM+UQZb6M7g5wbdrrAsmK7sGsxpEsHUR
 FI3ZA2zAWGWfKe4Ak0FDOktDdkahcZB7/JCCqHFloTEo4s7iPOnWptzMwKeHiadUU1i3
 1dCI8u3OuUJoDDnPPTJiBqZ49qIHp099acLp28zURPiBextMu180jzG1tHbliESECtkX
 djrA4F2SAM+uWkuzqwb0zZjBVQBBwPb717GYqjdJD/Tqvqjli+0uORthpH1uLx4x7MzI
 H4pfP07+26q4tq/ilM7i69HqwRbZIurYjqEISTEdrFRXNMyW0r6xyyDXaKyORIixlln2
 GNRg==
X-Received: by 10.49.106.226 with SMTP id gx2mr15923469qeb.67.1377933072146;
 Sat, 31 Aug 2013 00:11:12 -0700 (PDT)
Received: from [192.168.1.99] (c-107-3-3-0.hsd1.vt.comcast.net. [107.3.3.0])
 by mx.google.com with ESMTPSA id q4sm3505203qah.2.1969.12.31.16.00.00
 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
 Sat, 31 Aug 2013 00:11:11 -0700 (PDT)
From: Shane Celis <shane.celis@HIDDEN>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Subject: Possible bug in (web server)
Message-Id: <CB238240-1C7E-4703-B8DB-733764230E5F@HIDDEN>
Date: Sat, 31 Aug 2013 03:11:10 -0400
To: bug-guile@HIDDEN
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
X-Mailer: Apple Mail (2.1508)
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.4 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Hi all,

I found a bug in (web server) on Mac OS X, and when I compared against =
GNU/Linux I seem to have found a bug in (web client) there.  I've =
included a script and further details below.

#!/usr/local/bin/guile \
-e main -s
!#
;; guile-web-server-osx-bug.scm
;;
;; This script demonstrates a possible bug in Guile's web server on
;; Mac OS X.  And it demonstrates a possible bug in Guile's web client
;; on GNU/Linux.
;;
;; Problem
;; =3D=3D=3D=3D=3D=3D=3D
;;
;; Using Guile's (web server) with an example program, I ran into the
;; following issue on Mac OS X: If I ran
;; "./guile-web-server-osx-bug.scm server" and pointed my browser at
;; http://localhost:8080, the first request would work and be
;; displayed in my browser.  The second request would timeout.  I
;; compared this with Guile on GNU/Linux and found that the (web
;; server) worked fine, but the (web client) did not seem to work.
;;
;;
;; Reproduction
;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
;;
;; The script takes an argument "server" or "client [hostname/ip]".
;; When run as a server, it will say hello with an incremented
;; counter.  When run as a client, it will grab a couple of known
;; sites gnu.org, fsf.org, and then try localhost or the given
;; hostname on port 8080 twice, because on Mac OS X I saw the web
;; server work on the first request but not the second. The
;; hostname/ip the client is contacting is presumed to be a Guile web
;; server on the other end but doesn't have to be.
;;
;; If there were no bugs, this script should work like this:
;; $ ./guile-web-server-osx-bug.scm server &
;; Web server replied 'Hello World! 0'.
;; Web server replied 'Hello World! 1'.
;;
;; $ ./guile-web-server-osx-bug.scm client
;; Getting http://gnu.org... response #<<response> [...]
;;
;; Getting http://fsf.org... response #<<response> [...]
;;
;; Getting http://localhost:8080... response #<<response> [...]
;;
;; Getting http://localhost:8080... response #<<response> [...]
;;
;; Mac OS X bug
;; ------------
;;
;; Info
;; ----
;;=20
;; $ uname -a
;; Darwin mbp13.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 =
17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
;;
;; $ bash ./build-aux/config.guess
;; x86_64-apple-darwin12.4.0
;;
;; $ guile --version
;; guile (GNU Guile) 2.0.9 [...]
;;
;; $ ./config.status --config
;; 'LDFLAGS=3D-L/opt/local/lib' 'CPPFLAGS=3D-I/opt/local/include'
;;
;; Running
;; -------
;;=20
;; $ ./guile-web-server-osx-bug.scm server=20
;; Web server replied 'Hello World! 0'.
;;
;; --
;;
;; $ ./guile-web-server-osx-bug.scm client
;; Getting http://gnu.org... response #<<response> [...]
;;
;; Getting http://fsf.org... response #<<response> [...]
;;
;; Getting http://localhost:8080...SIGALRM called; timedout.
;;=20
;; If I try to connect to http://localhost:8080 through a web browser,
;; it does not connect; however, the web server does report that it
;; has replied.
;;
;; GNU/Linux bug
;; ------------
;;=20
;; Info
;; ----
;;
;; $ uname -a
;; Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux
;;
;; $ guile --version
;; guile (GNU Guile) 2.0.9 [...]
;;
;; $ bash ./build-aux/config.guess
;; i686-pc-linux-gnu
;;
;; $ ./config.status --config
;;
;; Running
;; -------
;;
;; $ ./guile-web-server-osx-bug.scm server=20
;; Web server replied 'Hello World! 0'.
;;
;; ---
;;
;; $ ./guile-web-server-osx-bug.scm client
;; Getting http://gnu.org... response #<<response> [...]
;;
;; Getting http://fsf.org... response #<<response> [...]
;;
;; Getting http://localhost:8080...SIGALRM called; timedout.
;;
;; If I try to connect to http://localhost:8080 through a web browser,
;; it works fine; so it seems like the (web client) is not working on
;; GNU/Linux and the (web server) is not working on Mac OS X.
;;=20

(use-modules (web server)
             (web client)
             (ice-9 optargs))

(define count 0)

(define (hello-world-handler request request-body)
  (let ((reply (format #f "Hello World! ~a" count)))
    (set! count (1+ count))
    (format #t "Web server replied '~a'.~%" reply)
    (values '((content-type . (text/plain)))
            reply)))

(define (start-server)
   (run-server hello-world-handler 'http '(#:port 8080)))

(define (check-url url)
  (format #t "Getting ~a..." url)
  (format #t " response ~a~%~%" (http-get url)))

(define* (run-client #:optional (ip "localhost"))
  (alarm 10)
  ;; Test some URLs that should work.
  (check-url "http://gnu.org")
  (check-url "http://fsf.org")
  ;; Try the web server's URL now twice.
  (check-url (format #f "http://~a:8080" ip))
  (check-url (format #f "http://~a:8080" ip)))

(sigaction SIGALRM (lambda (sig)
                     (format #t "SIGALRM called; timedout.~%")
                     (exit 1)))


(define (main args)
  (unless (or (=3D 2 (length args))
              (=3D 3 (length args)))
    (format (current-error-port) "Usage: ~a <server|client [ip]>~%" (car =
args))
    (exit 2))
  (cond
   ((string=3D "server" (cadr args))
    (start-server))
   ((string=3D "client" (cadr args))
    (apply run-client (cddr args)))))





Acknowledgement sent to Shane Celis <shane.celis@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#15227; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.