From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 02:53:09 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B9AB16A4CE; Sun, 10 Apr 2005 02:53:09 +0000 (GMT) Received: from sana.init-main.com (104.194.138.210.bn.2iij.net [210.138.194.104]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3AB2A43D2D; Sun, 10 Apr 2005 02:53:06 +0000 (GMT) (envelope-from takawata@init-main.com) Received: from init-main.com (localhost.init-main.com [127.0.0.1]) by sana.init-main.com (8.13.1/8.13.1) with ESMTP id j3A2pLEH055107; Sun, 10 Apr 2005 11:51:22 +0900 (JST) (envelope-from takawata@init-main.com) Message-Id: <200504100251.j3A2pLEH055107@sana.init-main.com> To: jeff@freebsd.org, bp@freebsd.org From: takawata@jp.freebsd.org Date: Sun, 10 Apr 2005 11:51:21 +0900 Sender: takawata@init-main.com cc: freebsd-fs@freebsd.org cc: freebsd-current@freebsd.org Subject: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 02:53:09 -0000 Hi I found the bug which is introduced at smbfs_vnops.c rev 1.58 This will make instant panic when you try to access file on mounted smbfs. This is caused by uninitialized vp. Index: smbfs_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/fs/smbfs/smbfs_vnops.c,v retrieving revision 1.59 diff -u -r1.59 smbfs_vnops.c --- smbfs_vnops.c 29 Mar 2005 13:06:58 -0000 1.59 +++ smbfs_vnops.c 10 Apr 2005 02:44:04 -0000 @@ -1118,7 +1118,8 @@ return error; if (error) { /* name was found */ struct vattr vattr; - + + vp = *vpp; killit = 0; error = VOP_GETATTR(vp, &vattr, cnp->cn_cred, td); /* From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 03:20:26 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7699116A4CE; Sun, 10 Apr 2005 03:20:26 +0000 (GMT) Received: from tarsier.geekcn.org (tarsier.geekcn.org [210.51.165.229]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67DF843D1D; Sun, 10 Apr 2005 03:20:23 +0000 (GMT) (envelope-from delphij@frontfree.net) Received: from beastie.frontfree.net (unknown [219.239.99.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTP id 7304BEB0F84; Sun, 10 Apr 2005 11:20:17 +0800 (CST) Received: from localhost (localhost.frontfree.net [127.0.0.1]) by beastie.frontfree.net (Postfix) with ESMTP id CC02F135376; Sun, 10 Apr 2005 11:20:15 +0800 (CST) Received: from beastie.frontfree.net ([127.0.0.1]) by localhost (beastie.frontfree.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 35430-11; Sun, 10 Apr 2005 11:20:10 +0800 (CST) Received: by beastie.frontfree.net (Postfix, from userid 1001) id 984C013273A; Sun, 10 Apr 2005 11:20:09 +0800 (CST) Date: Sun, 10 Apr 2005 11:20:09 +0800 From: Xin LI To: takawata@jp.freebsd.org Message-ID: <20050410032009.GA37675@frontfree.net> References: <200504100251.j3A2pLEH055107@sana.init-main.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" Content-Disposition: inline In-Reply-To: <200504100251.j3A2pLEH055107@sana.init-main.com> User-Agent: Mutt/1.4.2.1i X-GPG-key-ID/Fingerprint: 0xCAEEB8C0 / 43B8 B703 B8DD 0231 B333 DC28 39FB 93A0 CAEE B8C0 X-GPG-Public-Key: http://www.delphij.net/delphij.asc X-Operating-System: FreeBSD beastie.frontfree.net 5.3-RELEASE-p2 FreeBSD 5.3-RELEASE-p2 #15: Wed Dec 15 10:43:16 CST 2004 delphij@beastie.frontfree.net:/usr/obj/usr/src/sys/BEASTIE i386 X-URL: http://www.delphij.net X-By: delphij@beastie.frontfree.net X-Location: Beijing, China X-Virus-Scanned: by amavisd-new at frontfree.net cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: jeff@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 03:20:26 -0000 --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sun, Apr 10, 2005 at 11:51:21AM +0900, takawata@jp.freebsd.org wrote: > Hi I found the bug which is introduced at smbfs_vnops.c rev 1.58 >=20 > This will make instant panic when you try to access > file on mounted smbfs. >=20 > This is caused by uninitialized vp. Committed, thanks! Cheers, --=20 Xin LI http://www.delphij.net/ See complete headers for GPG key and other information. --ibTvN161/egqYuK8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCWJtp/cVsHxFZiIoRAkYbAJ9VmN+W5KjxwykT1nqC80smMDzJowCfVx4V 1Peaqc4bHwxEaddte3bxEsc= =zqSB -----END PGP SIGNATURE----- --ibTvN161/egqYuK8-- From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 09:24:30 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C9E616A4CE; Sun, 10 Apr 2005 09:24:30 +0000 (GMT) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9872343D2F; Sun, 10 Apr 2005 09:24:29 +0000 (GMT) (envelope-from q@uni.de) Received: from wrzx34.rz.uni-wuerzburg.de (wrzx34.rz.uni-wuerzburg.de [132.187.3.34]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 50497D8143; Sun, 10 Apr 2005 11:24:28 +0200 (CEST) Received: from virusscan (localhost [127.0.0.1]) by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id 3252CA790C; Sun, 10 Apr 2005 11:24:28 +0200 (CEST) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id 0D350A77E2; Sun, 10 Apr 2005 11:24:28 +0200 (CEST) Received: from frodo.galgenberg.net (wwsx14.win-screen.uni-wuerzburg.de [132.187.253.14]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 2A130D8143; Sun, 10 Apr 2005 11:24:27 +0200 (CEST) Received: from coyote.q.local (gb-21-237.galgenberg.net [172.16.21.237]) by frodo.galgenberg.net (8.13.1/8.13.1) with ESMTP id j3A9ORrh030329; Sun, 10 Apr 2005 11:24:27 +0200 (CEST) (envelope-from q@uni.de) Received: from roadrunner.q.local (roadrunner.q.local [192.168.0.148]) by coyote.q.local (8.13.1/8.13.1) with ESMTP id j3A9OQrY015207; Sun, 10 Apr 2005 11:24:26 +0200 (CEST) (envelope-from q@uni.de) Received: from roadrunner.q.local (localhost [127.0.0.1]) by roadrunner.q.local (8.13.3/8.13.1) with ESMTP id j3A9OPmc001715; Sun, 10 Apr 2005 11:24:25 +0200 (CEST) (envelope-from q@uni.de) Received: (from q@localhost) by roadrunner.q.local (8.13.3/8.13.1/Submit) id j3A9OH9d001714; Sun, 10 Apr 2005 11:24:17 +0200 (CEST) (envelope-from q@uni.de) Date: Sun, 10 Apr 2005 11:24:17 +0200 From: Ulrich Spoerlein To: takawata@jp.freebsd.org Message-ID: <20050410092417.GA774@galgenberg.net> Mail-Followup-To: takawata@jp.freebsd.org, jeff@freebsd.org, bp@freebsd.org, freebsd-fs@freebsd.org, freebsd-current@freebsd.org References: <200504100251.j3A2pLEH055107@sana.init-main.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline In-Reply-To: <200504100251.j3A2pLEH055107@sana.init-main.com> User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new (Rechenzentrum Universitaet Wuerzburg) cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: jeff@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 09:24:30 -0000 --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, 10.04.2005 at 11:51:21 +0900, takawata@jp.freebsd.org wrote: > This is caused by uninitialized vp. The compiler should warn about this. But something fishy is going on ... foo.c: int main(void) { int a; a+=3D1; return (0); } % gcc -O -W -Wall -Wuninitialized -Winit-self foo.c % icc -Wbrief -Wall foo.c foo.c(3): remark #592: variable "a" is used before its value is set % tdfc2 -Wall foo.c >/dev/null "foo.c", line 2: Warning: [ISO C90 6.6.2]: Variable 'a' may be used without being set. "foo.c", line 4: Warning: [ISO C90 6.6.2]: Variable 'a' not used since previous assignment. % lint -i foo.c foo.c(3): warning: a may be used before set [158] % splint foo.c foo.c: (in function main) foo.c:3:3: Variable a used before definition Any magical flags for gcc I'm missing? Ulrich Sp=F6rlein --=20 PGP Key ID: F0DB9F44 Encrypted mail welcome! Fingerprint: F1CE D062 0CA9 ADE3 349B 2FE8 980A C6B5 F0DB 9F44 Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn." didn't you understand? --mYCpIKhGyMATD0i+ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCWPDBmArGtfDbn0QRAlv6AKC77uh+sjX194oE+bKlqP4Vu7mCnQCdE6e+ jtlhJSlW7079+S6308/3i24= =Z3PH -----END PGP SIGNATURE----- --mYCpIKhGyMATD0i+-- From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 11:09:02 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 23FB716A4CE; Sun, 10 Apr 2005 11:09:02 +0000 (GMT) Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id C98B143D2F; Sun, 10 Apr 2005 11:09:00 +0000 (GMT) (envelope-from schweikh@schweikhardt.net) Received: by bremen.shuttle.de (Postfix, from userid 10) id DBBD23B8C3; Sun, 10 Apr 2005 13:08:58 +0200 (CEST) Received: from hal9000.schweikhardt.net (localhost [127.0.0.1]) j3AB8aD2003502; Sun, 10 Apr 2005 13:08:36 +0200 (CEST) (envelope-from schweikh@hal9000.schweikhardt.net) Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.13.3/8.13.3/Submit) id j3AB8aMK003501; Sun, 10 Apr 2005 13:08:36 +0200 (CEST) (envelope-from schweikh) Date: Sun, 10 Apr 2005 13:08:36 +0200 From: Jens Schweikhardt To: takawata@jp.freebsd.org, jeff@freebsd.org, bp@freebsd.org, freebsd-fs@freebsd.org, freebsd-current@freebsd.org Message-ID: <20050410110836.GA1355@schweikhardt.net> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410092417.GA774@galgenberg.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050410092417.GA774@galgenberg.net> User-Agent: Mutt/1.5.9i Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 11:09:02 -0000 On Sun, Apr 10, 2005 at 11:24:17AM +0200, Ulrich Spoerlein wrote: # On Sun, 10.04.2005 at 11:51:21 +0900, takawata@jp.freebsd.org wrote: # > This is caused by uninitialized vp. # # The compiler should warn about this. But something fishy is going on ... # # foo.c: # int main(void) { # int a; # a+=1; # return (0); # } Not so fishy. No warning because -O completely optimizes 'a' away. Try this instead: $ cat foo.c int main(void) { int a; a+=1; return a; } $ gcc -O -W -Wall -Wuninitialized -Winit-self foo.c foo.c: In function `main': foo.c:2: warning: 'a' might be used uninitialized in this function Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 11:46:02 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49C8D16A4CE; Sun, 10 Apr 2005 11:46:02 +0000 (GMT) Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id BB10D43D2F; Sun, 10 Apr 2005 11:46:01 +0000 (GMT) (envelope-from ellard@eecs.harvard.edu) Received: from localhost (localhost.eecs.harvard.edu [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id 2AF0354C865; Sun, 10 Apr 2005 07:45:51 -0400 (EDT) Received: from mail.eecs.harvard.edu ([127.0.0.1]) by localhost (bowser.eecs.harvard.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 68484-04; Sun, 10 Apr 2005 07:45:51 -0400 (EDT) Received: by mail.eecs.harvard.edu (Postfix, from userid 465) id E3F1C54C66F; Sun, 10 Apr 2005 07:45:50 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id E12F754C543; Sun, 10 Apr 2005 07:45:50 -0400 (EDT) Date: Sun, 10 Apr 2005 07:45:50 -0400 (EDT) From: Daniel Ellard To: Ulrich Spoerlein In-Reply-To: <20050410092417.GA774@galgenberg.net> Message-ID: <20050410074009.N66651@bowser.eecs.harvard.edu> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410092417.GA774@galgenberg.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at eecs.harvard.edu cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: jeff@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 11:46:02 -0000 On Sun, 10 Apr 2005, Ulrich Spoerlein wrote: > Date: Sun, 10 Apr 2005 11:24:17 +0200 > From: Ulrich Spoerlein > To: takawata@jp.freebsd.org > Cc: freebsd-fs@freebsd.org, bp@freebsd.org, jeff@freebsd.org, > freebsd-current@freebsd.org > Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 > > On Sun, 10.04.2005 at 11:51:21 +0900, takawata@jp.freebsd.org wrote: > > This is caused by uninitialized vp. > > The compiler should warn about this. But something fishy is going on ... > > foo.c: > int main(void) { > int a; > a+=1; > return (0); > } > > % gcc -O -W -Wall -Wuninitialized -Winit-self foo.c Certainly this is undesireable, but from what I can tell this happens because "a" is a dead variable and removed. (Look at the asm output and you'll see what I mean.) So it's debatable whether this is a bug. If you change the -O to -g, then the code for "a" is not removed -- but there's still no warning. I think this is a bug, because if the expression wasn't an innocuous a+=1 it could be a real problem if the variable wasn't removed. But people will also argue about this.. -Dan From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 12:04:48 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 654A116A4CE; Sun, 10 Apr 2005 12:04:48 +0000 (GMT) Received: from tensor.xs4all.nl (tensor.xs4all.nl [194.109.160.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id B785643D2F; Sun, 10 Apr 2005 12:04:47 +0000 (GMT) (envelope-from dimitry@andric.com) Received: from kilgore.dim (kilgore.dim [192.168.0.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.xs4all.nl (Postfix) with ESMTP id 0474622867; Sun, 10 Apr 2005 14:04:44 +0200 (CEST) Date: Sun, 10 Apr 2005 14:04:23 +0200 From: Dimitry Andric X-Priority: 3 (Normal) Message-ID: <1892195662.20050410140423@andric.com> To: Daniel Ellard In-Reply-To: <20050410074009.N66651@bowser.eecs.harvard.edu> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410092417.GA774@galgenberg.net> <20050410074009.N66651@bowser.eecs.harvard.edu> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="----------1291C69219E9F339" cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: Ulrich Spoerlein cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 12:04:48 -0000 ------------1291C69219E9F339 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit On 2005-04-10 at 13:45:50 Daniel Ellard wrote: >> int main(void) { >> int a; >> a+=1; >> return (0); >> } [snip] > If you change the -O to -g, then the code for "a" is not > removed -- but there's still no warning. I think this is > a bug, because if the expression wasn't an innocuous a+=1 > it could be a real problem if the variable wasn't removed. The idea here is that gcc sees that the value of a is never used, and therefore it doesn't have to warn. (Whether you agree with this, or not, is more of a political or philosophical question. ;) But as soon as you actually *do* something with a's value afterwards, it will start to complain. IOW, if you change main into: int main(void) { int a; a += 1; a++; //...bunch of other operations on a... ++a; a *= 3; return 0; } and gcc will still issue no warning. However, add one actual *use* of a: extern void f(int i); int main(void) { int a; a += 1; f(a); return 0; } and you'll get the warning you want... :) ------------1291C69219E9F339 Content-Type: application/pgp-signature -----BEGIN PGP MESSAGE----- Version: GnuPG v1.4.0 (MingW32) iD8DBQFCWRZHsF6jCi4glqMRAlQwAKCcHtIlJkcR3rdp2N99qz6JimAGLwCcDisx Xiqm/Q0yy9TeULi2QHQnwts= =hO98 -----END PGP MESSAGE----- ------------1291C69219E9F339-- From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 12:44:45 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7155B16A4CE; Sun, 10 Apr 2005 12:44:45 +0000 (GMT) Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id D664743D54; Sun, 10 Apr 2005 12:44:44 +0000 (GMT) (envelope-from ellard@eecs.harvard.edu) Received: from localhost (localhost.eecs.harvard.edu [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id 59EB654C9FB; Sun, 10 Apr 2005 08:44:44 -0400 (EDT) Received: from mail.eecs.harvard.edu ([127.0.0.1]) by localhost (bowser.eecs.harvard.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 77977-09; Sun, 10 Apr 2005 08:44:44 -0400 (EDT) Received: by mail.eecs.harvard.edu (Postfix, from userid 465) id 17DE054C9A0; Sun, 10 Apr 2005 08:44:44 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id 14E5154C993; Sun, 10 Apr 2005 08:44:44 -0400 (EDT) Date: Sun, 10 Apr 2005 08:44:44 -0400 (EDT) From: Daniel Ellard To: Dimitry Andric In-Reply-To: <1892195662.20050410140423@andric.com> Message-ID: <20050410082945.H66651@bowser.eecs.harvard.edu> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410074009.N66651@bowser.eecs.harvard.edu> <1892195662.20050410140423@andric.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at eecs.harvard.edu cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: Ulrich Spoerlein cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 12:44:45 -0000 On Sun, 10 Apr 2005, Dimitry Andric wrote: > > If you change the -O to -g, then the code for "a" is not > > removed -- but there's still no warning. I think this is > > a bug, because if the expression wasn't an innocuous a+=1 > > it could be a real problem if the variable wasn't removed. > > The idea here is that gcc sees that the value of a is never used, and > therefore it doesn't have to warn. (Whether you agree with this, or > not, is more of a political or philosophical question. ;) But as soon > as you actually *do* something with a's value afterwards, it will > start to complain. Well, I guess have to give an example... int main(void) { int a; int b[1]; a = b[a * 10000]; /* Uses the value of a. */ return (0); } If you compile this with -O, then the "a = " line is optimized away, and the deref of some random piece of memory goes away. If you compile this without the -O then now you have a deref to something whose address depends on an uninitialized variable. Sorry, that's bad. At least the gcc folk now do detect this old chestnut: { int a; a /= 0; } which was used to provoke arguments in compiler classes for many years. (Optimized, nothing happens. Unoptimized, a division-by-zero error happens...) My philosophy is that the compiler should warn you about things in the un-optimized, un-transformed code (because that's where I put my bugs -- if I've written code that has no effect, that's probably not what I meant). I'd rather get extraneous warnings than miss something. Of course, everyone is welcome to their own philosophy. (But how politics enter into this, I don't want to know.) -Dan From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 13:21:43 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E61016A4CE; Sun, 10 Apr 2005 13:21:43 +0000 (GMT) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id A5DFF43D3F; Sun, 10 Apr 2005 13:21:42 +0000 (GMT) (envelope-from q@uni.de) Received: from wrzx34.rz.uni-wuerzburg.de (wrzx34.rz.uni-wuerzburg.de [132.187.3.34]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id BC7F9D8408; Sun, 10 Apr 2005 15:21:41 +0200 (CEST) Received: from virusscan (localhost [127.0.0.1]) by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id A2265AC592; Sun, 10 Apr 2005 15:21:41 +0200 (CEST) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by wrzx34.rz.uni-wuerzburg.de (Postfix) with ESMTP id 6AF2EA77E2; Sun, 10 Apr 2005 15:21:41 +0200 (CEST) Received: from frodo.galgenberg.net (wwsx14.win-screen.uni-wuerzburg.de [132.187.253.14]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 4D117D8408; Sun, 10 Apr 2005 15:21:38 +0200 (CEST) Received: from coyote.q.local (gb-21-237.galgenberg.net [172.16.21.237]) by frodo.galgenberg.net (8.13.1/8.13.1) with ESMTP id j3ADLc9H010232; Sun, 10 Apr 2005 15:21:38 +0200 (CEST) (envelope-from q@uni.de) Received: from roadrunner.q.local (roadrunner.q.local [192.168.0.148]) by coyote.q.local (8.13.1/8.13.1) with ESMTP id j3ADLbrQ016229; Sun, 10 Apr 2005 15:21:37 +0200 (CEST) (envelope-from q@uni.de) Received: from roadrunner.q.local (localhost [127.0.0.1]) by roadrunner.q.local (8.13.3/8.13.1) with ESMTP id j3ADLbTF012473; Sun, 10 Apr 2005 15:21:37 +0200 (CEST) (envelope-from q@uni.de) Received: (from q@localhost) by roadrunner.q.local (8.13.3/8.13.1/Submit) id j3ADLZpa012472; Sun, 10 Apr 2005 15:21:35 +0200 (CEST) (envelope-from q@uni.de) Date: Sun, 10 Apr 2005 15:21:35 +0200 From: Ulrich Spoerlein To: Daniel Ellard Message-ID: <20050410132135.GB774@galgenberg.net> Mail-Followup-To: Daniel Ellard , takawata@jp.freebsd.org, freebsd-fs@freebsd.org, bp@freebsd.org, jeff@freebsd.org, freebsd-current@freebsd.org References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410092417.GA774@galgenberg.net> <20050410074009.N66651@bowser.eecs.harvard.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7ZAtKRhVyVSsbBD2" Content-Disposition: inline In-Reply-To: <20050410074009.N66651@bowser.eecs.harvard.edu> User-Agent: Mutt/1.5.8i X-Virus-Scanned: by amavisd-new (Rechenzentrum Universitaet Wuerzburg) cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: jeff@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 13:21:43 -0000 --7ZAtKRhVyVSsbBD2 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, 10.04.2005 at 07:45:50 -0400, Daniel Ellard wrote: > Certainly this is undesireable, but from what I can tell this > happens because "a" is a dead variable and removed. (Look at > the asm output and you'll see what I mean.) So it's debatable > whether this is a bug. >=20 > If you change the -O to -g, then the code for "a" is not > removed -- but there's still no warning. I think this is > a bug, because if the expression wasn't an innocuous a+=3D1 > it could be a real problem if the variable wasn't removed. > But people will also argue about this.. You are right, using something like this: #include int main(void) { int a,b; a+=3D1; b=3D1+a; printf("%d\n", b); return (0); } I get a warning: % cc -O -W -Wall -Wuninitialized foo.c foo.c: In function `main': foo.c:3: warning: 'a' might be used uninitialized in this function Sorry for the noise then. /me needs to learn asm some day. Ulrich Sp=F6rlein --=20 PGP Key ID: F0DB9F44 Encrypted mail welcome! Fingerprint: F1CE D062 0CA9 ADE3 349B 2FE8 980A C6B5 F0DB 9F44 Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn." didn't you understand? --7ZAtKRhVyVSsbBD2 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQFCWShfmArGtfDbn0QRAiE8AJ9+UpRfN2zL4Pgj9lvXsDx8LLQKcACgxgv6 6mXAFnU8+XSLDHhh8FL2YqY= =KQlv -----END PGP SIGNATURE----- --7ZAtKRhVyVSsbBD2-- From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 17:10:39 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66E8616A4CE; Sun, 10 Apr 2005 17:10:39 +0000 (GMT) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2513243D1F; Sun, 10 Apr 2005 17:10:39 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 8D52C5DA0; Sun, 10 Apr 2005 13:10:38 -0400 (EDT) Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 85577-01; Sun, 10 Apr 2005 13:10:36 -0400 (EDT) Received: from [192.168.1.3] (pool-68-161-53-96.ny325.east.verizon.net [68.161.53.96]) by pi.codefab.com (Postfix) with ESMTP id 378895C85; Sun, 10 Apr 2005 13:10:36 -0400 (EDT) Message-ID: <42595E04.60705@mac.com> Date: Sun, 10 Apr 2005 13:10:28 -0400 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050319 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Ellard References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410074009.N66651@bowser.eecs.harvard.edu> <1892195662.20050410140423@andric.com> <20050410082945.H66651@bowser.eecs.harvard.edu> In-Reply-To: <20050410082945.H66651@bowser.eecs.harvard.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at codefab.com cc: freebsd-fs@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 17:10:39 -0000 Daniel Ellard wrote: > On Sun, 10 Apr 2005, Dimitry Andric wrote: [ ... ] > At least the gcc folk now do detect this old chestnut: > > { > int a; > > a /= 0; > } > > which was used to provoke arguments in compiler > classes for many years. (Optimized, nothing happens. > Unoptimized, a division-by-zero error happens...) Great example. If the optimized code fails to generate a division-by-zero error here, the optimizer is buggy. (I won't quote Aho, Sethi, and Ullman again.... :-) -- -Chuck From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 17:49:42 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4A1CB16A4CF; Sun, 10 Apr 2005 17:49:42 +0000 (GMT) Received: from VARK.MIT.EDU (VARK.MIT.EDU [18.95.3.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id B629D43D49; Sun, 10 Apr 2005 17:49:41 +0000 (GMT) (envelope-from das@FreeBSD.ORG) Received: from VARK.MIT.EDU (localhost [127.0.0.1]) by VARK.MIT.EDU (8.13.3/8.13.1) with ESMTP id j3AHncbR004938; Sun, 10 Apr 2005 13:49:38 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.MIT.EDU (8.13.3/8.13.1/Submit) id j3AHncA2004937; Sun, 10 Apr 2005 13:49:38 -0400 (EDT) (envelope-from das@FreeBSD.ORG) Date: Sun, 10 Apr 2005 13:49:38 -0400 From: David Schultz To: Chuck Swiger Message-ID: <20050410174938.GA4842@VARK.MIT.EDU> Mail-Followup-To: Chuck Swiger , Daniel Ellard , freebsd-fs@FreeBSD.ORG, freebsd-current@FreeBSD.ORG References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410074009.N66651@bowser.eecs.harvard.edu> <1892195662.20050410140423@andric.com> <20050410082945.H66651@bowser.eecs.harvard.edu> <42595E04.60705@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42595E04.60705@mac.com> cc: freebsd-fs@FreeBSD.ORG cc: freebsd-current@FreeBSD.ORG Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 17:49:42 -0000 On Sun, Apr 10, 2005, Chuck Swiger wrote: > Daniel Ellard wrote: > >On Sun, 10 Apr 2005, Dimitry Andric wrote: > [ ... ] > >At least the gcc folk now do detect this old chestnut: > > > > { > > int a; > > > > a /= 0; > > } > > > >which was used to provoke arguments in compiler > >classes for many years. (Optimized, nothing happens. > >Unoptimized, a division-by-zero error happens...) > > Great example. > > If the optimized code fails to generate a division-by-zero error here, the > optimizer is buggy. (I won't quote Aho, Sethi, and Ullman again.... :-) gcc's optimizer is notoriously bad with side-effects like this, particularly for floating-point code. The C99 standard requires that the compiler support the FENV_ACCESS pragma to tell the compiler that (among other things) it must not optimize away arithmetic that may generate an exception as a side-effect, but gcc doesn't implement it. Worse yet, gcc defaults to assuming that it *is* allowed to optimize such arithmetic operations away, even in expressions such as '1.0 / 0.0' where it's clear what the programmer wanted to happen. A number of routines in libm don't work properly at -O2 as a result of this, and in several places we play tricks such as declaring variables to be volatile or 'long double' just to trick the optimizer. IIRC, Steve Moshier wrote some gcc patches to fix this, but nobody ever committed them... From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 17:55:39 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 029D116A4CE; Sun, 10 Apr 2005 17:55:39 +0000 (GMT) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57B8D43D2D; Sun, 10 Apr 2005 17:55:38 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])j3AHtXml022309; Mon, 11 Apr 2005 03:55:33 +1000 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j3AHtVIo014029; Mon, 11 Apr 2005 03:55:32 +1000 Date: Mon, 11 Apr 2005 03:55:31 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Chuck Swiger In-Reply-To: <42595E04.60705@mac.com> Message-ID: <20050411032601.S55302@delplex.bde.org> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <1892195662.20050410140423@andric.com><42595E04.60705@mac.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: freebsd-fs@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 17:55:39 -0000 On Sun, 10 Apr 2005, Chuck Swiger wrote: > Daniel Ellard wrote: >> On Sun, 10 Apr 2005, Dimitry Andric wrote: > [ ... ] >> At least the gcc folk now do detect this old chestnut: >> >> { >> int a; >> >> a /= 0; >> } >> >> which was used to provoke arguments in compiler >> classes for many years. (Optimized, nothing happens. >> Unoptimized, a division-by-zero error happens...) > > Great example. > > If the optimized code fails to generate a division-by-zero error here, the > optimizer is buggy. (I won't quote Aho, Sethi, and Ullman again.... :-) No, the behaviour is undefined. The compiler can do anything. gcc now emits a warning even with -O0. A similar example with "double a;" is more interesting. This also gives undefined behaviour (C99 6.5.5[#5]). However, this is bogus if there is a floating point infinity. C99 has support for IEEE floating point and it is clearly intended that the behaviour of 1.0/0.0 is to give +Inf and raise the divide-by-zero exception, but I couldn't see anywhere in the C99 draft n869.txt where this is spelled out (raising of the divide-by-zero exception is spelled out for lots of math functions but doesn't seem to be mentioned for plain division). Also, in C99 with IEEE FP support, "#pragma STDC FENV_ACCESS *" should affect the behaviour. I'm not sure of the details, but think that programs can only depend on getting the divide-by-zero exception if FENV_ACCESS is ON. gcc still doesn't support this pragma, so it does several wrong things with FENV_ACCESS ON: - for "a = 1.0 / 0.0;", it evaluates 1.0 / 0.0 at compile time (even with -O0) so it never raises a divide-by-zero exception. - "a /= 0.0;" where "a" is not otherwise used is not dead code, since it should have the side effect of raising the exception, but gcc considers this code to be dead. Bruce From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 18:04:55 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6F90D16A4CF for ; Sun, 10 Apr 2005 18:04:55 +0000 (GMT) Received: from av3-2-sn4.m-sp.skanova.net (av3-2-sn4.m-sp.skanova.net [81.228.10.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id F1D4943D1D for ; Sun, 10 Apr 2005 18:04:53 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: by av3-2-sn4.m-sp.skanova.net (Postfix, from userid 502) id D6E3037E51; Sun, 10 Apr 2005 20:04:52 +0200 (CEST) Received: from smtp4-2-sn4.m-sp.skanova.net (smtp4-2-sn4.m-sp.skanova.net [81.228.10.180]) by av3-2-sn4.m-sp.skanova.net (Postfix) with ESMTP id C5A7037E42 for ; Sun, 10 Apr 2005 20:04:52 +0200 (CEST) Received: from falcon.midgard.homeip.net (h201n1fls24o1048.bredband.comhem.se [212.181.162.201]) by smtp4-2-sn4.m-sp.skanova.net (Postfix) with SMTP id 526A237E46 for ; Sun, 10 Apr 2005 20:04:52 +0200 (CEST) Received: (qmail 1026 invoked by uid 1001); 10 Apr 2005 18:04:50 -0000 Date: Sun, 10 Apr 2005 20:04:50 +0200 From: Erik Trulsson To: Chuck Swiger Message-ID: <20050410180450.GA963@falcon.midgard.homeip.net> Mail-Followup-To: Chuck Swiger , Daniel Ellard , freebsd-fs@freebsd.org, freebsd-current@freebsd.org References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410074009.N66651@bowser.eecs.harvard.edu> <1892195662.20050410140423@andric.com> <20050410082945.H66651@bowser.eecs.harvard.edu> <42595E04.60705@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42595E04.60705@mac.com> User-Agent: Mutt/1.5.9i cc: freebsd-fs@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 18:04:55 -0000 On Sun, Apr 10, 2005 at 01:10:28PM -0400, Chuck Swiger wrote: > Daniel Ellard wrote: > >On Sun, 10 Apr 2005, Dimitry Andric wrote: > [ ... ] > >At least the gcc folk now do detect this old chestnut: > > > > { > > int a; > > > > a /= 0; > > } > > > >which was used to provoke arguments in compiler > >classes for many years. (Optimized, nothing happens. > >Unoptimized, a division-by-zero error happens...) > > Great example. > > If the optimized code fails to generate a division-by-zero error here, the > optimizer is buggy. Not at all. Division by zero means undefined behaviour (at least in C.) Undefined behaviour means *anything* may happen - including no error happening. A compiler optimizing away the division-by-zero is perfectly correct in doing so. (It is also perfectly correct to not optimize away the error.) > (I won't quote Aho, Sethi, and Ullman again.... :-) No, please don't - especially since that quote you are so fond of isn't *quite* correct - an optimizer is allowed to change the output of a program as long as the new output is also correct according to the language specification. (Language specifications often do not specify every detail, with the result that for a given program it can be the case that more than one output can be correct. In C any instance of undefined behaviour in a program means that *no* aspect of the program is defined and therefore all different outputs will be equally correct.) -- Erik Trulsson ertr1013@student.uu.se From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 18:43:31 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B031416A4CE; Sun, 10 Apr 2005 18:43:31 +0000 (GMT) Received: from gate.bitblocks.com (bitblocks.com [209.204.185.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id 69CF243D1D; Sun, 10 Apr 2005 18:43:31 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost [127.0.0.1]) by gate.bitblocks.com (8.13.3/8.13.1) with ESMTP id j3AIhUh0046427; Sun, 10 Apr 2005 11:43:31 -0700 (PDT) (envelope-from bakul@bitblocks.com) Message-Id: <200504101843.j3AIhUh0046427@gate.bitblocks.com> To: Bruce Evans In-reply-to: Your message of "Mon, 11 Apr 2005 03:55:31 +1000." <20050411032601.S55302@delplex.bde.org> Date: Sun, 10 Apr 2005 11:43:30 -0700 From: Bakul Shah cc: freebsd-fs@freebsd.org cc: Chuck Swiger cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 18:43:31 -0000 > A similar example with "double a;" is more interesting. This also > gives undefined behaviour (C99 6.5.5[#5]). However, this is bogus if > there is a floating point infinity. C99 has support for IEEE floating > point and it is clearly intended that the behaviour of 1.0/0.0 is to > give +Inf and raise the divide-by-zero exception, but I couldn't see > anywhere in the C99 draft n869.txt where this is spelled out (raising of > the divide-by-zero exception is spelled out for lots of math functions > but doesn't seem to be mentioned for plain division). This is indirectly spelled out in draft n2764.txt in annex F: F.3 Operators and functions [#1] C operators and functions provide IEC 60559 required and recommended facilities as listed below. -- The +, -, *, and / operators provide the IEC 60559 add, subtract, multiply, and divide operations. IEC 60599 (aka IEEE754) clearly states the behavior for divide by zero. 6.5.5 does say x/0 is undefined but if __STDC_IEC_559__ is defined then IEEE behavior is expected. I haven't checked gassy-c (gcc) for conformance. From owner-freebsd-fs@FreeBSD.ORG Mon Apr 11 16:15:45 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8504716A4CE for ; Mon, 11 Apr 2005 16:15:45 +0000 (GMT) Received: from ns.cygnus.de (ns.cygnus.de [194.221.99.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0C39043D45 for ; Mon, 11 Apr 2005 16:15:44 +0000 (GMT) (envelope-from gth@cmex.de) Received: from [192.168.1.4] (p54995C39.dip.t-dialin.net [84.153.92.57]) j3BGUGS19710 for ; Mon, 11 Apr 2005 18:30:17 +0200 X-Authentication-Warning: ns.cygnus.de: Host p54995C39.dip.t-dialin.net [84.153.92.57] claimed to be [192.168.1.4] From: Gunther Thiel To: freebsd-fs@freebsd.org Message-Id: <1113236140.685.33.camel@darthvader> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 11 Apr 2005 18:15:40 +0200 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Stackable Filesystems/deadlock/VI_DOOMED X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2005 16:15:45 -0000 I am working on stackable filesystems using 5.3-STABLE and figured that there are still deadlock problems when using the nullfs template on a busy, stressed machine. >From what I have experienced, apparently the deadlock occurs when trying to get a new node while it's being recycled. What I have seen in the VFS code of the CURRENT branch looks very promising (VI_DOOMED instead of VI_XLOCK!), but as I have no clue when new VFS stuff will be in a solid state, I wanted to ask if the problem is at all solveable with the VFS concept under 5.3 and if so, how. If it is not solveable (which is my personal guess) would someone mind giving me a hint on dependencies when I would only like to use as much stuff from CURRENT to move to new VFS concept (with all the ostentatious risks)? Thanks very much! Gunther From owner-freebsd-fs@FreeBSD.ORG Thu Apr 14 02:09:42 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB36B16A4CE; Thu, 14 Apr 2005 02:09:42 +0000 (GMT) Received: from axe-inc.co.jp (axegw.axe-inc.co.jp [61.199.217.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F76943D45; Thu, 14 Apr 2005 02:09:41 +0000 (GMT) (envelope-from takawata@axe-inc.co.jp) Received: from localhost (localhost [127.0.0.1]) by axe-inc.co.jp (8.9.3+3.2W/3.7W) with SMTP id LAA17486; Thu, 14 Apr 2005 11:09:40 +0900 (JST) Message-Id: <200504140209.LAA17486@axe-inc.co.jp> X-Authentication-Warning: axegw.axe-inc.co.jp: localhost [127.0.0.1] didn't use HELO protocol To: freebsd-gnats-submit@FreeBSD.org, daichi@freebsd.org From: takawata@jp.freebsd.org Date: Thu, 14 Apr 2005 11:09:39 +0900 Sender: takawata@axe-inc.co.jp cc: freebsd-fs@freebsd.org cc: takawata@freebsd.org Subject: Re: kern/78110: [patch] fixed multibyte treatment of Samba FS (smb/ctx.c). X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2005 02:09:43 -0000 I wrote a patch that can applied to -CURRENT at a few days ago. Please review it. If anyone don't make objections in a week, I'll commit it. Index: contrib/smbfs/lib/smb/ctx.c =================================================================== RCS file: /home/ncvs/src/contrib/smbfs/lib/smb/ctx.c,v retrieving revision 1.3 diff -u -r1.3 ctx.c --- contrib/smbfs/lib/smb/ctx.c 27 Jul 2003 11:41:38 -0000 1.3 +++ contrib/smbfs/lib/smb/ctx.c 7 Apr 2005 23:30:42 -0000 @@ -473,8 +473,6 @@ struct sockaddr *sap; struct sockaddr_nb *salocal, *saserver; char *cp; - u_char cstbl[256]; - u_int i; int error = 0; ctx->ct_flags &= ~SMBCF_RESOLVED; @@ -496,7 +494,7 @@ if (error) return error; if (ssn->ioc_localcs[0] == 0) - strcpy(ssn->ioc_localcs, "default"); /* XXX: locale name ? */ + strcpy(ssn->ioc_localcs, "ISO8859-1"); error = smb_addiconvtbl("tolower", ssn->ioc_localcs, nls_lower); if (error) return error; @@ -504,18 +502,9 @@ if (error) return error; if (ssn->ioc_servercs[0] != 0) { - for(i = 0; i < sizeof(cstbl); i++) - cstbl[i] = i; - nls_mem_toext(cstbl, cstbl, sizeof(cstbl)); - error = smb_addiconvtbl(ssn->ioc_servercs, ssn->ioc_localcs, cstbl); - if (error) - return error; - for(i = 0; i < sizeof(cstbl); i++) - cstbl[i] = i; - nls_mem_toloc(cstbl, cstbl, sizeof(cstbl)); - error = smb_addiconvtbl(ssn->ioc_localcs, ssn->ioc_servercs, cstbl); - if (error) - return error; + error = kiconv_add_xlat16_cspairs + (ssn->ioc_localcs, ssn->ioc_servercs); + if (error) return error; } if (ctx->ct_srvaddr) { error = nb_resolvehost_in(ctx->ct_srvaddr, &sap); Index: sys/fs/smbfs/smbfs_smb.c =================================================================== RCS file: /home/ncvs/src/sys/fs/smbfs/smbfs_smb.c,v retrieving revision 1.14 diff -u -r1.14 smbfs_smb.c --- sys/fs/smbfs/smbfs_smb.c 6 Jan 2005 18:10:41 -0000 1.14 +++ sys/fs/smbfs/smbfs_smb.c 7 Apr 2005 23:30:42 -0000 @@ -1449,8 +1449,8 @@ continue; break; } - smbfs_fname_tolocal(SSTOVC(ctx->f_ssp), ctx->f_name, ctx->f_nmlen, - ctx->f_dnp->n_mount->sm_caseopt); + smbfs_fname_tolocal(SSTOVC(ctx->f_ssp), ctx->f_name, &ctx->f_nmlen, + ctx->f_dnp->n_mount->sm_caseopt); ctx->f_attr.fa_ino = smbfs_getino(ctx->f_dnp, ctx->f_name, ctx->f_nmlen); return 0; } Index: sys/fs/smbfs/smbfs_subr.c =================================================================== RCS file: /home/ncvs/src/sys/fs/smbfs/smbfs_subr.c,v retrieving revision 1.5 diff -u -r1.5 smbfs_subr.c --- sys/fs/smbfs/smbfs_subr.c 6 Jan 2005 18:10:41 -0000 1.5 +++ sys/fs/smbfs/smbfs_subr.c 7 Apr 2005 23:40:24 -0000 @@ -316,13 +316,33 @@ } int -smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int nmlen, int caseopt) +smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int *nmlen, int caseopt) { -/* if (caseopt & SMB_CS_UPPER) - iconv_convmem(vcp->vc_toupper, name, name, nmlen); - else if (caseopt & SMB_CS_LOWER) - iconv_convmem(vcp->vc_tolower, name, name, nmlen);*/ - if (vcp->vc_tolocal) - iconv_convmem(vcp->vc_tolocal, name, name, nmlen); - return 0; + int copt = (caseopt == SMB_CS_LOWER ? KICONV_FROM_LOWER : + (caseopt == SMB_CS_UPPER ? KICONV_FROM_UPPER : 0)); + int error = 0; + int ilen = *nmlen; + int olen; + char *ibuf = name; + char outbuf[SMB_MAXFNAMELEN]; + char *obuf = outbuf; + + if (vcp->vc_tolocal) { + olen = sizeof(outbuf); + bzero(outbuf, sizeof(outbuf)); + + /* + error = iconv_conv_case + (vcp->vc_tolocal, NULL, NULL, &obuf, &olen, copt); + if (error) return error; + */ + + error = iconv_conv_case + (vcp->vc_tolocal, (const char **)&ibuf, &ilen, &obuf, &olen, copt); + if (!error) { + *nmlen = sizeof(outbuf) - olen; + memcpy(name, outbuf, *nmlen); + } + } + return error; } Index: sys/fs/smbfs/smbfs_subr.h =================================================================== RCS file: /home/ncvs/src/sys/fs/smbfs/smbfs_subr.h,v retrieving revision 1.5 diff -u -r1.5 smbfs_subr.h --- sys/fs/smbfs/smbfs_subr.h 10 Feb 2005 12:07:02 -0000 1.5 +++ sys/fs/smbfs/smbfs_subr.h 7 Apr 2005 23:30:42 -0000 @@ -174,7 +174,7 @@ int smbfs_smb_lookup(struct smbnode *dnp, const char *name, int nmlen, struct smbfattr *fap, struct smb_cred *scred); -int smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int nmlen, int caseopt); +int smbfs_fname_tolocal(struct smb_vc *vcp, char *name, int *nmlen, int caseopt); void smb_time_local2server(struct timespec *tsp, int tzoff, u_long *seconds); void smb_time_server2local(u_long seconds, int tzoff, struct timespec *tsp); Index: usr.bin/smbutil/Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/smbutil/Makefile,v retrieving revision 1.1 diff -u -r1.1 Makefile --- usr.bin/smbutil/Makefile 14 Dec 2001 11:41:22 -0000 1.1 +++ usr.bin/smbutil/Makefile 12 Apr 2005 04:32:52 -0000 @@ -3,8 +3,8 @@ PROG= smbutil SRCS= smbutil.c dumptree.c login.c lookup.c view.c print.c -DPADD= ${LIBSMB} -LDADD= -lsmb +DPADD= ${LIBSMB} ${LIBKICONV} +LDADD= -lsmb -lkiconv CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs CFLAGS+= -I${CONTRIBDIR}/include Index: usr.sbin/mount_smbfs/Makefile =================================================================== RCS file: /home/ncvs/src/usr.sbin/mount_smbfs/Makefile,v retrieving revision 1.6 diff -u -r1.6 Makefile --- usr.sbin/mount_smbfs/Makefile 21 Dec 2004 09:59:44 -0000 1.6 +++ usr.sbin/mount_smbfs/Makefile 12 Apr 2005 04:32:26 -0000 @@ -9,8 +9,8 @@ CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs CFLAGS+= -DSMBFS -I${MOUNTDIR} -I${CONTRIBDIR}/include -LDADD= -lsmb -DPADD= ${LIBSMB} +LDADD= -lsmb -lkiconv +DPADD= ${LIBSMB} ${LIBKICONV} # Needs to be dynamically linked for optional dlopen() access to # userland libiconv (see the -E option).