From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: Bug in Guile's Posix Networking Date: Sat, 12 Feb 2011 21:22:39 -0500 Message-ID: References: <877hdb76cq.fsf@vir.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=000e0cd6a97ef92aee049c209ab2 X-Trace: dough.gmane.org 1297563776 5939 80.91.229.12 (13 Feb 2011 02:22:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 13 Feb 2011 02:22:56 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Feb 13 03:22:46 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PoRbp-00067G-Em for guile-devel@m.gmane.org; Sun, 13 Feb 2011 03:22:45 +0100 Original-Received: from localhost ([127.0.0.1]:55474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoRbp-0005JD-0u for guile-devel@m.gmane.org; Sat, 12 Feb 2011 21:22:45 -0500 Original-Received: from [140.186.70.92] (port=48199 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PoRbl-0005Iy-UP for guile-devel@gnu.org; Sat, 12 Feb 2011 21:22:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PoRbk-0007AZ-Qm for guile-devel@gnu.org; Sat, 12 Feb 2011 21:22:41 -0500 Original-Received: from mail-yx0-f169.google.com ([209.85.213.169]:61775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PoRbk-0007AL-79 for guile-devel@gnu.org; Sat, 12 Feb 2011 21:22:40 -0500 Original-Received: by yxl31 with SMTP id 31so1804368yxl.0 for ; Sat, 12 Feb 2011 18:22:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=3SK0ijLVDGrMtYP0wjTNJxfVs/vkoqZVrH5SipM51+A=; b=hGFnCp8DKmG8TXZyOpyAv1obwOeP4Uhg82k9QH0itxoXX1Ibhn0MBuhp+y93ZrotLT 2rKySbBB0/VCo7n2WsF1mGvG2Y4TeCw8QDH8wnbRDSab9s1dCAAdS/w1PMeDcRgrXupL BnD1o5/k8pWLHmeL+768GuwN3wiW6iw18VkRg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=gZbE+I2bB5Gg1DtgQPdL5tJO+hUB+79hm1vEO12J74M8J3WDVNLNyOF1nlFHi619sT oo5jHqGqNyowkxZ6+EpGt6Z+OADJwlOiziRHVGHQG67WmQzHbYI+lXLzjkRyXfOiMmhv KxFkrQWBvOntgJ5P1JxjeUk6JAXL5qhLtLjFA= Original-Received: by 10.150.11.16 with SMTP id 16mr2572010ybk.444.1297563759749; Sat, 12 Feb 2011 18:22:39 -0800 (PST) Original-Received: by 10.147.40.5 with HTTP; Sat, 12 Feb 2011 18:22:39 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: jgpQa1vs7Vl1FqSxrW2T2QWCFNA X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11587 Archived-At: --000e0cd6a97ef92aee049c209ab2 Content-Type: text/plain; charset=ISO-8859-1 Hello again, The attached patch fixes the problem for me, and I believe zeroing some data structures before they're used won't hurt things for anyone else. Noah On Sat, Feb 12, 2011 at 8:45 PM, Noah Lavine wrote: > Hi all, > > I think I have isolated the error (although in fact there are two > things that should be fixed). > > I gdb'd Guile's executable and looked at the struct sockaddr just > before it was passed to bind. There were two mistakes. > > First of all, that struct has an sa_len field which is supposed to > contain its length, but in fact contained junk. Second of all, it > should have been padded with 8 bytes of zeros at the end, but it > wasn't. After experimenting a bit, it turns out that padding with > zeros was what made the difference, but probably the sa_len field > should be fixed anyway. I'll work on a patch for this. > > Noah > > On Sat, Feb 12, 2011 at 8:22 PM, Noah Lavine wrote: >> Hi, >> >>> #x49 is 73 :) >> >> If I knew a facepalm emoticon, I would use it now. :) >> >>> Could the lseek could be the problem? >> >> Maybe, but I suspect not. My man page for lseek says that lseek will >> fail with ESPIPE if it is called on a socket, and my errno.h defines >> ESPIPE to be 29, which is the error we got. So that's what's happening >> there. >> >> However, I looked to see where the lseek call was coming from, and it >> happens in scm_fdes_to_port, on line 564 of fports.c. The lseek is >> done for the purpose of checking whether the port supports lseek, and >> when it returns -1, we put an entry into some data structure (port >> table?) saying that it doesn't support random access. So it looks like >> that error is actually expected in the port code. >> >> Noah >> > --000e0cd6a97ef92aee049c209ab2 Content-Type: application/octet-stream; name="0001-libguile-socket.c-fix-use-of-uninitialized-memory.patch" Content-Disposition: attachment; filename="0001-libguile-socket.c-fix-use-of-uninitialized-memory.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gk3by92t0 RnJvbSA2ZGFlYzhjZTllY2M0Nzg0YTQyNDc5ZDFhZDEwMTQzNWEwNDA4ZWNmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBOb2FoIExhdmluZSA8bmxhdmluZUBoYXZlcmZvcmQuZWR1PgpE YXRlOiBTYXQsIDEyIEZlYiAyMDExIDIxO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